Git Product home page Git Product logo

Comments (6)

inamiy avatar inamiy commented on August 20, 2024

In your example, you are registering event-based routes but attaching state-based handler, so it doesn't react to any event-triggering.

To fix this, please replace:

// register handler for state-based transition, e.g. `machine <- .State0`
machine.addHandler(.Any => .Any) { ... }

to:

// register handler for event-based transition, e.g. `machine <-! .Event0`
machine.addHandler(event: .Event0) { ... }

from swiftstate.

toshi0383 avatar toshi0383 commented on August 20, 2024

I thought it was working in previous version, though ?

from swiftstate.

inamiy avatar inamiy commented on August 20, 2024

Yes, previous ver 3.x was working in that way (equal to addEventHandler()).
From ver 4.0.0, you need to use machine.addHandler(event:) instead.

P.S.
For reacting to any events, you can use machine.addHandler(event: .Any).

from swiftstate.

inamiy avatar inamiy commented on August 20, 2024

Updated README.md in 84d4b42.

from swiftstate.

toshi0383 avatar toshi0383 commented on August 20, 2024

πŸ‘
I see that. Thanks !

from swiftstate.

philipbel avatar philipbel commented on August 20, 2024

Hello.

I find this behavior surprising. I was just playing with SwiftState, and wanted to model the state machine using a mix of events and states. The idea being that I would attach handlers to the states, but send events to the machine to transition.

I understand this is not possibleβ€”I would have to choose events or states, but not both.

from swiftstate.

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.