Version française
Home     About     Download     Resources     Contact us    
Browse thread
React.E.switch issue.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Guillaume Yziquel <guillaume.yziquel@c...>
Subject: Re: React.E.switch issue.
Guillaume Yziquel a écrit :
> Hello.

Hi again.

> 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

I've replaced the previous code by the following piece of code, and it 
now works...

>   let event_starting_at ?drop:(drop = false) str = React.E.fold begin fun accu chunk -> accu^chunk end str
>     begin match drop with | false -> received_event | true -> React.E.drop_once received_event end 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 ~drop: true unparsed_text) in

Now, is this a bug or a feature?

All the best,

Guillaume Yziquel.

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