I'll expand the answer a little.
Space leak occur when we are continuous creating more frp nodes in a way they retain a strong reference even though they may never be used again. And the graph just keeps growing while its evaluated.
Sodium uses Weak References pointing forwards to frp nodes that are effected by a change in a frp node. And if you stick to the applicative functor interface provided your safe. switchC
/ switchS
is pretty safe too as long as it is not miss used.
Older monadic frp implementations provided bind
which made it too easy to keep recreating frp nodes which only needed to be created once (evaluation of bind continuation repetitively), and also if you accidentally created a monadic loop you get in that situation where you keep creating more strongly referenced frp nodes continuously that never get released even through they may never be used again (strong reference capture by lambda in bind's continuation). This is still possible, but harder to do in sodium. switchC
is like join
, and a map
with a join
used together is the same as bind
.