Browse thread
React.E.switch issue.
-
Guillaume Yziquel
- Guillaume Yziquel
-
Daniel_Bünzli
- Guillaume Yziquel
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2009-09-24 (14:19) |
From: | Guillaume Yziquel <guillaume.yziquel@c...> |
Subject: | Re: React.E.switch issue. |
Daniel Bünzli a écrit : >> My issue is that the 'reinitialise_with' function is called in a >> function 'phi' which is used in the following way: >> >> let message_event = React.E.map phi to_be_parsed_event. > > Cannot really make sense out of your snippets of code. What I want to do is the following: The server sends events with chunks of string that I want to parse. I accumulate the string chunks (with React.E.fold) until I can parse some server message out of it. When some message is parsed, I discard this part of the event, and I install another "accumulating event" (accumulating with React.E.fold). In order to discard and renew the "accumulating event", I send an event to the event of event. This is why I use the React.E.switch construct. The output of React.E.switch is an event that can hold, for example the following sequence of values: My fi My first mes My first message. My s (Here is where the event of event is renewed:) My s My secon My second mess etc... > However this phi functions seems to invoke a primitive event sending function Yes. phi is the function that parses the messages from the server. So it has to send an event to renew the "accumulating event". > and that's explicitely prohibited by the documentation. Primitive event > sending/signal setting functions cannot be invoked as side effects > inside update cycles (see doc of E.create/S.create). OK. So this is not a bug, nor a feature. > Not sure what you are trying to achieve but I suspect fixed point > combinators (E.fix/S.fix) may help you to solve your problem. I tried to look into this, but I did not see how they could help me with my specific issue. > Best, > > Daniel For now, I'm using a workaround, but I'll try to see how I can make this clean... Many thanks for your answer. -- Guillaume Yziquel http://yziquel.homelinux.org/