I've encountered two subtle but serious problems using om with core.async.
The first one is illustrated by this code:
First, one obvious solution here is to move the dump-chan inside the form state.
However, it's written this way to illustrate the error which originally arose in a
dialog component that took both an action channel that receives button presses
and a dialog content component. It exposed the action channel in this way in
order to be flexible.
I believe the cause of this error is that when you toggle the form in the demo
to off, it unmounts the component. However, the go-block is still active and
listening to the channel. When you toggle the form back on, a new component
is created and mounted. Now you have two components listening on the same
channel!
The ideal solution might be to find a way to end the go block when the component
unmounts. This is easy to do on a case by case basis, but not easy to do in a
completely generic fashion. Here is one solution:
The second problem is easy to fix, however, I don't understand why it happens.
Instead of initializing the dump channel in the base components state, we initialize
it when creating the form component. As soon as you start typing into the form
the channel breaks. It was suggested on irc that this might be because of a
re-render of base would create a new channel, but the form component will not
be re-mounted because it's already mounted. However, putting in some debug
code shows that there is no re-render of the base component occurring between
when the channel works and when it doesn't.
I'm posting this here mostly to warn people to be wary of these situations. Of
course, if you have any suggestions or explanations for these I'd love to hear them.
Alex