Coder Social home page Coder Social logo

Comments (3)

roman01la avatar roman01la commented on June 23, 2024

Thanks for reporting this. Iā€™m on vacation now, will take a look later.

from citrus.

DjebbZ avatar DjebbZ commented on June 23, 2024

I've been bitten by the same root cause of this problem just today.

For dispatch!, the side effects are always executed before changing the state. Here's the code for latest Citrus 3.2.
For dispatch-sync!, the execution order between the :state effect and other side effects depends on the order of traversal of Citrus's custom doseq macro. See the code.

Makes me think that there's a problem of predictability and/or coherence, or at least a documentation problem. If code needs to be changed, I don't know how to make it non-breaking.

from citrus.

martinklepsch avatar martinklepsch commented on June 23, 2024

I think with the the recent :citrus/handler refactorings (#50 & #59) the behavior should be more consistent:

(schedule-update!
batched-updates
scheduled?
(fn batch-runner []
(let [events @queue]
(clear-queue! queue)
(citrus-handler this events)))))
(dispatch-sync! [this cname event args]
(assert (some? event) (str "dispatch! was called without event name:" (pr-str [cname event args])))
(citrus-handler this [[cname event args]]))

Specifically :state will always be executed last:

(m/doseq [effect (dissoc effects :state)]
(let [[eff-type effect] effect]
(when (s/check-asserts?)
(when-let [spec (s/get-spec eff-type)]
(s/assert spec effect)))
(when-let [handler (get effect-handlers eff-type)]
(handler reconciler ctrl effect))))
(if (contains? effects :state)
(recur (assoc state ctrl (:state effects)) events)

I guess this is a breaking change in some ways and we will document this in the release notes.

from citrus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.