I've managed to create a cycle in my bacon-powered application, so I need some advice on how to break it.
Let's say we have several properties which carry some state of the application. This state is supposed to be stored via HTML5 History API (pushState
) and thus I combine those properties to an object and execute a pushState
on it. However, I also need to cover popstate
events, so on every popstate
(back button, etc.) I split the state object back into single properties and inject them into their original streams.
Now I've got myself a cycle: since those property streams are the same streams I got my pushState
from in the first place, pushState
is called again, duplicating states on the stack and making the back button useless.
This is of course my mistake, however, I don't see a good solution apart from splitting each property stream into two and combining them differently in pushState
/popState
-specific cases. But that seems rather unelegant -- is there any canonical way to avoid this kind of cycles?