I'm trying to throttle a search field in purescript-halogen. What I have so far:
eval (Search search next) = do
State st <- get
-- clear last timeout
liftEff' $ maybe (return unit) T.clearTimeout st.searchTimeout
-- new timeout
t <- liftEff' $ T.timeout 1000 $ return unit -- how to send action from here???
modify (\(State s) -> State $ s { searchTimeout = Just t })
pure next
I thought about saving the UI driver in a global Var
and send new actions from there, but this seems very hacky to me.
Or maybe there's another way to do that?