mpizenberg / elm-debounce Goto Github PK
View Code? Open in Web Editor NEWControl the processing of commands with debouncing and throttling
License: Mozilla Public License 2.0
Control the processing of commands with debouncing and throttling
License: Mozilla Public License 2.0
There are currently a lot of packages called elm-debounce
or similar.
It's hard to choose and to understand the specificity of each. Since my package is not exclusively about debouncing but also throttling, I should rename it to give it a better fit identity.
The new name candidate is elm-control-msg. It fits well with the modules names also.
Internally, the implementation is based on a state monad. It shall be useful to extract it as its own package, or reuse the already quite good package folkertdev/elm-state.
In an attempt at minimizing modifications, I have end up with a new message update (instead of modifying existing one) and a small modification of the view event.
I wonder if there is not a better way to do so, by just modifying update, and not touching the view?
Just wondering if it would be possible to control messages using browser animation frame somehow?
From the examples it's not clear to me whether I can reduce the number of Cmds I send out through my port.
My scenario is an onInput
handler on a password field to update the model and call a port with the password value to derive some cryptographic keys. Now I don't need to go through the port on every key stroke. Delaying the update the model is weird, because in my view I render input field with the value in the model, i.e. input [value model.value]
so if I don't update the model the view will lag behind to the point that it doesn't even work properly. Now I wish I could only go through the port if 250ms have passed after the last onInput event rather than calling the relatively expensive port function each and every time.
I'd appreciate either an example or a statement in the docs whether this is possible and if so, how.
It's clear to me that I can manually keep track of the time and do the accounting on my end. But I'm investigating the solution space now and the more code I can recycle, the happier I will be.
Hello!
Thanks for building this cool and useful thing! I've been very happy with it since installing, but encountered some trouble today while debugging. I built my app with the debug
flag and clicked in the history pane, then tried to export it. I got the following message:
Cannot use Import or Export
The Msgs.Msg
type of your program cannot be reliably serialized for history files.
Functions cannot be serialized, nor can values that contain functions. This is a problem in these places:
Control.Control
can contain functions.
The good news is that having values like this in your message type is not
so great in the long run. You are better off using simpler data, like
union types, in your messages. From there, your update
function can pattern match on that data and call whatever functions, JSON
decoders, etc. you need. This makes the code much more explicit and easy to
follow for other readers (or you in a few months!)
So that's a bummer! Do you have any idea for workarounds?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.