caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* React.E.switch issue.
@ 2009-09-24  7:40 Guillaume Yziquel
  2009-09-24  8:01 ` Guillaume Yziquel
  2009-09-24 13:42 ` Daniel Bünzli
  0 siblings, 2 replies; 5+ messages in thread
From: Guillaume Yziquel @ 2009-09-24  7:40 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: caml-list

Hello.

Here is a piece of code that I am having issue. I'm trying to use React 
to parse reactively a server output. I have the following event definition:

>   let event_starting_at str = React.E.fold begin fun accu chunk -> accu^chunk end str received_event in 
>   let to_be_parsed_event_of_event, set_to_be_parsed_event_of_event = React.E.create () in
>   let to_be_parsed_event = React.E.switch (event_starting_at "") to_be_parsed_event_of_event in
>   let reinitialise_with unparsed_text = set_to_be_parsed_event_of_event (event_starting_at unparsed_text) in

String chunks from the server are received by the 'received_event' 
event, on the first line.

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.

phi is the parsing function, so I'm not reproducing it directly here. 
However, you would have the behaviour described further below with the 
following code:

let phi string_chunk =
   let new_string_chunk = String.copy string_chunk in
   reinitialise_with new_string_chunk;
   new_string_chunk

This creates hiccups in the events.

For example, at different time intervals, with to_be_parsed_event, I get:

	q
	qqw
	qqwwe
	qqwweer
	qqwweerrt

etc... where I'd like in fact to have

	q
	qw
	qwe
	qwer
	qwert

Advice would be appreciated on how to correct this.

All the best,

-- 
      Guillaume Yziquel
http://yziquel.homelinux.org/


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-09-28 11:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-24  7:40 React.E.switch issue Guillaume Yziquel
2009-09-24  8:01 ` Guillaume Yziquel
2009-09-24 13:42 ` Daniel Bünzli
2009-09-24 14:14   ` Guillaume Yziquel
2009-09-28 11:57     ` Daniel Bünzli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).