import { ObservableSuggestionListState } from '@ulangi/ulangi-observable' ; import { DictionaryEntryDelegate } from '../dictionary/DictionaryEntryDelegate' ; export class SuggestionListDelegate { private suggestionListState : ObservableSuggestionListState ; private dictionaryEntryDelegate : DictionaryEntryDelegate ; private onSelect : ( fieldName : string , value : string ) => string ; public constructor ( suggestionListState , dictionaryEntryDelegate , onSelect ) { this . suggestionListState = suggestionListState ; this . dictionaryEntryDelegate = dictionaryEntryDelegate ; this . onSelect = onSelect ; } public getSuggestions ( ) { this . dictionaryEntryDelegate . getDictionaryEntry ( this . suggestionListState . currentVocabularyTerm ) ; } public clearSuggestions ( ) { this . dictionaryEntryDelegate . clearDictionaryEntry ( ) ; } public onSelectSuggestion ( fieldName , value ) { this . suggestionListState . currentVocabularyText = this . onSelect ( fieldName , value ) ; } }