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/

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to