Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom attributes to transitions and lifecycle events #163

Open
frapan opened this issue Jul 19, 2018 · 0 comments
Open

Add custom attributes to transitions and lifecycle events #163

frapan opened this issue Jul 19, 2018 · 0 comments

Comments

@frapan
Copy link

frapan commented Jul 19, 2018

I have a state machine to manage the different states of a product, eg: product-inserted, product-confirmed, price-inserted, price-confirmed, etc.
Different users can change the state of the product, depending on their roles, eg: logistics can insert product, marketing can confirm price, etc.
I was thinking about checking the role in a generic onBeforeTransition event and declaring the allowed roles directly in the transitions array, eg:

transitions: [
  { name: 'insert-product', from: 'none', to: 'product-inserted', role: 'logistics' },
  { name: 'confirm-price, from: 'price-inserted', to: 'price-confirmed', role: 'marketing' },
]

Unfortunately, the role attribute is not passed to the lifecycle events.
What do you think about passing the whole transition object to the lifecycle events instead of just name, from and to?
In this way that would be a breaking change, but it could also be implemented in different ways:

  • add the transition object without removing name, from and to
  • add only the custom attributes

I guess that custom attributes could be useful in many situations.
What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant