Fork me on GitHub
#hyperfiddle
<
2023-04-27
>
Lidor Cohen10:04:31

Hi all, I'm experimenting with reverse of control style: https://cycle.js.org/ i.e the computed state variable reads events from input and compute its state, (as opposed to the event handlers sets some state variable). What is the most idiomatic way to extract an event stream from event handlers? I know missionary can expose a very similar abstraction to Rx so I'm guessing that there should be some simple primitive I could use to get an event stream out of event handler. Thanks in advance šŸ˜„

Dustin Getz10:04:41

m/observe

šŸ™ 2
Lidor Cohen11:04:51

If I'm setting listeners on all events but no one is reading them are they still costing performance? or is there some kind of optimization on the graph that eliminates orphan signals?

Dustin Getz12:04:43

event callbacks are eager (due to how the platform works), use (m/relieve rf) to relieve backpressure by dumping events into an accumulator via reducing fn. the accumulator is then lazily sampled thereafter

šŸ™ 2
Dustin Getz12:04:23

see http://electric.hyperfiddle.net section about backpressure and lazy clocks, and please ask clarifying questions here so i can improve the docs

šŸ‘ 2
Lidor Cohen12:04:33

> ā€¢ The clocks pause when the browser page is not visible (i.e. you switch tabs), confirm it Wasn't able to confirm it, switched tabs but clocks kept on running

Lidor Cohen12:04:48

@U09K620SG did you happen to think about the nature of signals vs imperative state (swap!) at the event handlers (either dom events or async tasks) boundaries? This is where FPR seems to fall back to imperative, and I wonder about that: ā€¢ is this the best abstraction for "importing" data into the signals graph? if so why? ā€¢ what happens if we try to take the declarative (frp) approach all the way (like cycle.js did)? If you had the chance to think about the nature of external inputs and how they fit best into the frp system I'd love to get some insight šŸ™‚ Thanks

xificurC12:04:30

electric compiles to https://github.com/leonoel/missionary which supports discrete streams and continuous signals under a single protocol

Dustin Getz17:04:54

m/observe is the way to import events into the dataflow graph