I want to have something happen as long as the mouse is down, and then stop it when the mouse is up. I imagine that gate() is the right tool for the job - and I'd even think that gate is kindof a common solution, but the book says it's not a primitive and I don't see it used often when searching through the github repos.
My guess is that filter and merge are a better way somehow... but I don't see how to do that.
Here's some sample code (typescript). It works perfectly, just wondering what the solution without gate would look like
sTicks is a Stream<number>
and cLoad is a Cell<boolean>
(set via Cell.send() when media assets are loaded) and cTouch is a Cell<TOUCH>
set via an IO listener and TOUCH is an enum
//prevent anything from happening until ui is loaded
const sReady = sTicks.gate(cLoad);
//don't make new objects unless mouse is down
const sCreating = sReady.gate(cTouch.map(t => t == TOUCH.DOWN ? true : false));
//if ui is loaded, run updates
sReady.listen(deltaTime =>
bunnies.forEach(bunny => bunny.update(deltaTime)))
//if mouse is down, make a bunny
sCreating.listen(() => {
bunnies.push(makeBunny());
})