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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Re: React switch with newly created events.
> However, it may happen (and it does happen) that as soon as this new
> React.event is created, an event is fired before the React.E.switch has been
> executed to replace the old event by the new event.

You are creating a new update cycle inside another update cycle and
this is disallowed. No primitives are allowed to update in an update
cycle (to be precise unless the primitive does not belong to the
dependency graph of the update cycle).

> -1- clutter my code with mutexes to synchronise the whole stuff, with the
> disadvantage that there is not, to my knowledge, to execute a function just
> after the React.E.switch function has effectively switched events.

I don't understand what you are saying (a word must be missing). But
yes you need to serialize the updates, see
http://erratique.ch/software/react/doc/React#update but I guess you
already know that.
.
> -2- look for a way in React to do it within React only. Which would mean to
> somehow implement within React a way to switch to a newly created event,
> without race conditions.

You can perfectly switch to a newly created event, primitive or not.
If the event is not a primitive it may even have an occurence in the
same update cycle (e.g. if the dynamic creation depends on the
updating primitive itself). However if it's a primitive event it
cannot have an occurence in the same update cycle as this would start
a new update cycle and this is disallowed.

Daniel