Hi Max,

Yes, I started there :-). There are two other debounce packages registered.
http://package.elm-lang.org/packages/fredcy/elm-debouncer/latest
http://package.elm-lang.org/packages/athanclark/elm-debouncer/latest

Basically, all three (counting mine), perform several Process.sleep that
are never cancelled, but filtered.
As sometimes happens, the interface of each package matches the vision of
the author.

In my case, I wanted the minimum idiomatic expression to go from:

type Msg = UserInput String | ...
view model = ... input [ onInput UserInput ] [] ...

to a debounced event: notify the model, but not too often :-). So

view model = ... input [ onInput (*deb1* UserInput) ] [] ...

where deb1 : (a -> Msg) -> (a -> Msg).

or even debounce from the update instead of the view. These scenarios are
supported and I am happy with the interface, but not the implementation.

Going to the outside world, with subscription, on this loop of UserInput
seems overkill.
Since all debounce packages use the same underlying technique either that's
it (for now?), or there might be another way to address this thing.
Debouncing is important so pages can feel comfortable to the user, but nice
to the server also ;-).



On Wed, Sep 21, 2016 at 3:06 AM Max Goldstein <maxgoldste...@gmail.com>
wrote:

> Well for starters you can search for "debounce" on the package catalog and
> look at what other people have done.
>
> Let's say I'm debouncing the many Msgs that can come in from moving the
> mouse. I would expect that when the mouse stays put for a supplied
> duration, I'm given that mouse position.
>
> But after a few minutes of thought, I can't come up with a good non-native
> API. If I can dream of additions to core, I might want
>
> debounce : Time -> Sub msg -> Sub msg
>
> Which would work great for mouse positions and keep Model and update
> completely uncluttered, but I'm not sure if it would help all use-cases
> since it's only for Subs and would require an addition to core.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elm-discuss/TUEqLPpHVCE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Brian J. Cardiff - Manas Technology Solutions
[ar.phone] 4796.0232 #BCR(227)
[us.phone] 312.612.1050  #BCR(227)
[email] bcard...@manas.com.ar
[web] www.manas.com.ar
[weblog] http://weblogs.manas.com.ar/bcardiff/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to