#mkSuggester Source

mkSuggester :: forall a. Eq a => FetchFn a -> Effect (SuggesterInstance a)

Create a suggester with the default API backend: Affjax.get & decodeJson, no input debounce, and no input transformations.

#mkSuggester' Source

mkSuggester' :: forall a. Eq a => SuggesterSettings a -> Effect (SuggesterInstance a)

Create a suggester with an alternate API backend.

#FetchFn Source

type FetchFn a = Terms -> Aff (Either String (Array a))

#SuggesterSettings Source

type SuggesterSettings a = { fetch :: FetchFn a, inputDebounce :: Milliseconds, inputTransformer :: Terms -> Terms }

#SuggesterInstance Source

type SuggesterInstance a = { send :: Terms -> Effect Unit, subscribe :: (Suggestions a -> Effect Unit) -> Effect Unit }

A suggester instance has a send function for providing new terms and a subscribe function for listening for new suggestions. The subscribe function will always be called with the most up to date suggestions for the latest terms sent, even if a previous search is slow to complete. Subscribers immediately receive the most recent result set.