The queues are FIFO since it's using core.async under the hood. Obviously
if you have things like server putting events on the queue, you can't
guarantee order, but relative order (eg doing two dispatches one after
another) will be in order.

Yeah, I'd probably do with something like:

(let [player (subscribe [:active-player])]
  (fn []
    [:div {:on-click (dispatch [:do-something @player])} ...]))

That is, have the event control which player it gets applied to. This way
the handler does not need any knowledge of this at all and can use path
middleware to focus in on only what it cares about (the game board, in the
case of selecting a cell).

On Fri, 3 Apr 2015 at 12:46 Rafał Cieślak <[email protected]> wrote:

> > I would also triple check that the order in which events are dispatched
> are the order in which they are executed.
>
> I was worried about it, too, but re-frame docs explain it quite clear.
>
> https://github.com/Day8/re-frame#talking-to-a-server
>
> > dispatch will cause a handler function to be called. But the process is
> async. The call is queued.
> > if you (further) dispatch in a handler, then that will be async too. The
> associated handler is queued for later processing. Why? Partially because
> handlers are given a snapshot of the app-db and can't be nested.
>
> Problems can show up later in case I'd be doing some async operations like
> saving to local storage or making HTTP requests – I wouldn't be able to
> guarantee the order in which they get queued.
>
> So yeah, the pureness of the second approach has many benefits and makes
> the code more confident.
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to