Coder Social home page Coder Social logo

heycarsten / ember-fsm Goto Github PK

View Code? Open in Web Editor NEW
39.0 39.0 14.0 395 KB

[Maintenance Mode] A promise-aware finite state machine implementation for Ember

License: MIT License

JavaScript 96.50% HTML 2.85% CSS 0.65%
ember ember-addon fsm javascript state-machine

ember-fsm's People

Contributors

andypyesc avatar catz avatar ghedamat avatar heycarsten avatar hhff avatar john-kurkowski avatar lxcodes avatar tobsch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ember-fsm's Issues

willExit & didExit appear to run when entering that state

heycarsten !

I may be being a silly boy, but it appears that willExit and didExit run on entering a state.

  /* Begin State Machine Definition */
  fsmEvents: {
    toIdentity: {
      transition: {
        from: '$all',
        to: 'identity'
        willExit() { console.log('i ran when entering the identity state! ...') },
        didExit() { console.log('...then i also ran when entering the identity state!') }
      }
    },
  },

This is being used in an FSM#Stateful service.

I was hoping to use willExit() to return a promise that will authenticate the current user when attempting a transition from the identity step. Am I being a silly boy??

Hope you're great Carsten!! Miss you man

ES6

Ensure Ember FSM can be used easily in Ember CLI projects.

Allow mixin to set the current state on object initialization

My usecase for the FSM is a workflow manager for tasks. I'd love to persist the current state into a DB and revive the FSM later to promote the item. Being able to set currentState on init will allow for this. Or am I on the wrong track and is this feature already possible?

$all does not include $initial

There's probably a good reason for this, but I was hoping to do:

fsmEvents: {
  toCart: {
    transition: { $all: 'cart' }
}

Instead I need to do:

fsmEvents: {
  toCart: {
    transition: { 
      from: ['$initial', '$all'],
      to: 'cart'
    }
  }
}

Feels like $all should include $initial - but maybe I'm missing something?

Octane-compatible fork (was: Current maintainer status)

Hi, just checking if this message reaches any other maintainers of this repo / package that Carsten might have added prior to his passing in 2019.

I am not aware of any other maintainers but wanted to verify as I am working on minimal updates to provide compatibility with Ember 4.x / Octane (purely to aid in the upgrade process in an Ember app that still uses this library for now). If there are, I could submit a PR, otherwise my intention is to publish a fork in the next few days.

It should work with prototype extensions disabled

just updated an addon that uses this to CLI 0.0.23 (which includes a package for addons that forces ember to disable prototype extensions, to ensure max compatibility)

Noticed ember-fsm uses .contains

Just flagging this, shouldn't be too hard

Auto populate canXXX properties

I love the automatic isInXXX properties, it's genius for logic in templates. It would be really nice to have canXXX properties too. XXX is replaced with the name of a transition.

This allows for templates to add action buttons when these actions are available.

What is your opinion, is this hard to implement?

I think recomputing the guards will be hard though.

Initial State: Support for callbacks

Hi,

it would be great if a function would be accepted as initialState to properly sync the FSM with a model that comes with a state and is persisted.

Best,
Tobias

Ember 1.8 compatibility

Ember changed its use of the states property, particularly in views. After upgrading 1.7 -> 1.8, my app is peppered with

DEPRECATION: Usage of states is deprecated, use _states instead.

This particularly conflicts if I mix Ember.FSM.Stateful into a component (a view). ember-fsm's states property conflicts with CoreView's, resulting in

TypeError: Cannot read property 'enter' of undefined.

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.