From a1b2f0344a59e24ae4d16f1689a02ba72ced2b53 Mon Sep 17 00:00:00 2001 From: Kero van Gelder Date: Wed, 5 Apr 2023 14:33:00 +0200 Subject: =?UTF-8?q?=F0=9F=90=9B=20Avoid=20a=20race=20condition=20when=20di?= =?UTF-8?q?spatch=20is=20used=20twice=20from=20outside=20(#8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Upgrade examples to lustre 2.0 * Upgrade to gleam 0.27.0 * Fix: avoid a race condition when dispatch is used twice from outside E.g. websocket open + websocket msg arriving Application returns a Cmd from update(model, msg) but the Effect handler is *not* ran be React 18 before the websocket msg-arriving is handled by the Reducer. Result: The Cmd returned by update(model, msg) is dropped silently. --------- Co-authored-by: Kero van Gelder --- test/example/main.gleam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/example/main.gleam') diff --git a/test/example/main.gleam b/test/example/main.gleam index 7d9c063..21c4067 100644 --- a/test/example/main.gleam +++ b/test/example/main.gleam @@ -15,7 +15,7 @@ pub fn main () -> Nil { // `lustre.start` can return an `Error` if no DOM element is found that matches // the selector. This is a fatal error for our examples, so we panic if that // happens. - assert Ok(dispatch) = lustre.start(program, selector) + let assert Ok(dispatch) = lustre.start(program, selector) dispatch(Counter(counter.Incr)) dispatch(Counter(counter.Incr)) -- cgit v1.2.3