reflex
reflex copied to clipboard
More Reflex.Time and related functions
See https://gist.github.com/lspitzner/18e679006765b308e9dbc41b06e86bbb
-
gateGather: an accumulating gate -
maskCalmE: behaves like throttle, but not controlled by time, but by input dynamic -
conditionalBuffer: a buffer that can conditionally retain one input event value -
fanBy:(eventsWhenFalse, eventWhenTrue) = fanBy pred inputE -
fanOn:(eventsWhenFalse, eventWhenTrue) = fanOn boolBeh inputE -
triggerDelay: behaves like delay, but not controlled by time, but my a second input event -
executeAsync1Calm: perform an event asynchronously, but do not run more than one at a time -
executeAsync1CalmWith: with custom forker function -
gateThrottle: likethrottlebut without any accumulation. better for debouncing bursts.
All names open for discussion.
Only gateThrottle actually uses time, so I doubt that Reflex.Time is the right module, but not sure where else these would belong.
I have added conditionalBuffer because it was necessary to fix the semantics of executeAsync1Calm(With). Preventing logic loops when inputs get connected to outputs is tricky.. hope things are fixed now.
To be clear, I am ready to turn this into a PR, presuming that there is interest in having these included and that we decide on which module to put these in.