import { ObservableMultipleChoiceFormState , ObservableMultipleChoiceResult , Observer , } from '@ulangi/ulangi-observable' ; export class MultipleChoiceFormDelegate { private observer : Observer ; private multipleChoiceFormState : ObservableMultipleChoiceFormState ; private multipleChoiceResult : ObservableMultipleChoiceResult ; public constructor ( observer , multipleChoiceFormState , multipleChoiceResult ) { this . observer = observer ; this . multipleChoiceFormState = multipleChoiceFormState ; this . multipleChoiceResult = multipleChoiceResult ; } public checkAnswer ( answer , callback ) { this . multipleChoiceFormState . selectedAnswers . push ( answer ) ; if ( this . multipleChoiceFormState . hasCorrectAnswer === true ) { this . multipleChoiceResult . correctAttempts ++ ; this . multipleChoiceFormState . containerAnimation = 'fadeOutDown' ; this . observer . when ( ( ) : boolean => this . multipleChoiceFormState . containerAnimation === null , ( ) : void => { callback . onAnswerCorrect ( ) ; } ) ; } else { this . multipleChoiceResult . incorrectAttempts ++ ; this . multipleChoiceFormState . containerAnimation = 'shake' ; callback . onAnswerIncorrect ( ) ; } } }