From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 9CC6DBBAF for ; Wed, 23 Dec 2009 14:24:06 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnYBADupMUtKfU4akGdsb2JhbACDbZcjPwEBAQEJCQwHEwOsFIFbhWKIOwECAwWBKoIuVgSCfYg0 X-IronPort-AV: E=Sophos;i="4.47,442,1257116400"; d="scan'208";a="40469432" Received: from ey-out-2122.google.com ([74.125.78.26]) by mail3-smtp-sop.national.inria.fr with ESMTP; 23 Dec 2009 14:23:51 +0100 Received: by ey-out-2122.google.com with SMTP id 22so134478eye.7 for ; Wed, 23 Dec 2009 05:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=m8I23JI4WzeFvKUYRVryGLEtDXwPTXzrwiUBbn3rJhc=; b=D/xqU3Np053OEwsXKRNh3QJskNo9s/41U4I2h3Yh5ClofIcIeoOEeSHmeCOGnDPg// JGeSfJlqF1ZU0AYxQXCRtCvQ/DPPGHdqkjYQhPm3ShT9jerHxu9CFdNK2PYIjJLzsQZD pdWBsFqUzAPo0VTMngOkeeoypsKSB4aDmYDnY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=qGUYaPGPaEMRLCYT/HBtKcoXnrE3+Q8JBW7psIq2cj4FiHYmKE+cx4t6gAsmVbhwej n6nqy1jytR0wr30S0SZ/RF73rEVokrou8EVjpQyv7/U2eLoDVgtW2No5zUPbXwPXXLXR hhldDQFmXMq4T02//3+5sZNUsMKN32OFrFfkE= MIME-Version: 1.0 Sender: daniel.c.buenzli@gmail.com Received: by 10.213.98.205 with SMTP id r13mr2522972ebn.89.1261574630574; Wed, 23 Dec 2009 05:23:50 -0800 (PST) In-Reply-To: <4B320EFA.9050609@citycable.ch> References: <4B320EFA.9050609@citycable.ch> Date: Wed, 23 Dec 2009 22:23:50 +0900 X-Google-Sender-Auth: df539c74fe27f2c4 Message-ID: <91a3da520912230523w74ff5fe8i9b0f8eb9f2c015c7@mail.gmail.com> Subject: Re: React switch with newly created events. From: =?UTF-8?Q?Daniel_B=C3=BCnzli?= To: guillaume.yziquel@citycable.ch Cc: OCaml List Content-Type: text/plain; charset=UTF-8 X-Spam: no; 0.00; buenzli:01 mutexes:01 serialize:01 occurence:01 occurence:01 graph:01 dependency:01 primitives:01 primitive:02 primitive:02 dynamic:03 daniel:04 daniel:04 depends:04 guess:04 > 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