GithubHelp home page GithubHelp logo

Comments (2)

ifandelse avatar ifandelse commented on August 10, 2024

@estaylorco - I haven't actually run into a use-case yet where I've needed this (separating states/handler config from instantiation), so unfortunately it's not something that machina likely supports out-of-the-box. Just curious - what sort of constraints are driving the separation of the two for you?

The newer machina bits that I'm messing with locally include a "behavioral" FSM approach where state and behavior are separate - and that might fit this use case well. It's slow going because of umpteen thousand other OSS efforts at the moment, but I'm planning to take some time off in December and get through it if I haven't before then....

from machina.js.

estaylorco avatar estaylorco commented on August 10, 2024

@ifandelse - Actually, it turns out that there's no need for machina to make the separation. I've made the separation myself, separating the creation of the object literal that gets passed into the FSM's constructor, and the instantiation of the FSM itself.

The use case is a consequence of the fact that JavaScript does not allow LHS expressions in object literals:

{
    '/view/changed': function () {}
}

is acceptable, but

{
    messageTopics.view_changed: function () {}
}

is not.

That forces me to do one of two things: a) live with magic strings, or b) construct the object literal using bracketed notation (i.e. events[messageTopics.view_changed] = function () {}), or something to that effect.

I should mention that I'm using machina.postal.

from machina.js.

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.