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

parallel event in a state #166

Closed
emclab opened this issue Dec 1, 2015 · 1 comment
Closed

parallel event in a state #166

emclab opened this issue Dec 1, 2015 · 1 comment

Comments

@emclab
Copy link

emclab commented Dec 1, 2015

Here is an example from [Geekq/workflow][1] which we are using in our rails app:

workflow do
state :new do
event :submit, :transitions_to => :awaiting_review
end
state :awaiting_review do
event :review, :transitions_to => :being_reviewed
end
state :being_reviewed do
event :accept, :transitions_to => :accepted
event :reject, :transitions_to => :rejected
end
state :accepted
state :rejected
end

The events in a state are mutually exclusive. For example, only one of events accept and reject is going to happen. How to add a parallel event like send_bill, in :awaiting_review? Both send bill and review are going to happen at the same time. Here is what we would like to have (parallel_event is NOT Geekq/workflow definition):

state :awaiting_review do
  parallel_event :review, :transitions_to => :being_reviewed
  parallel_event :send_bill, :transitions_to => :being_reviewed
end
@emclab
Copy link
Author

emclab commented Dec 23, 2015

We end up keeping transitions_to the same state if the other paralle event hasn't been fired or to next state if all other parallel events have been fired. Here is an example for one event:

state :awaiting_review do
event :review, :transitions_to => :awaiting_review,
:if => proc {other_events_not_filed}
event :review, :transitions_to => :next_state,
:if => proc {other_event_did_filed}
end

@geekq geekq closed this as completed May 29, 2022
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

2 participants