-
Notifications
You must be signed in to change notification settings - Fork 132
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 terminal states to TKStateMachine. #15
base: master
Are you sure you want to change the base?
Conversation
/** | ||
Returns a Boolean value that indicates if the receiver has transitioned into one of the states in `terminalStates`. | ||
*/ | ||
@property (nonatomic, readonly) BOOL terminated; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be isTerminated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly. I deliberated
this a bit myself, but I felt like if it wasn't just "terminated" that it
should really be "hasTerminated" but that doesn't really go with the naming
convention. I guess terminated isn't a great word... maybe finished would
be better... shrug
What's the use case on this? |
I was trying to come up with a way of nesting state machines. Specifically, |
@@ -237,9 +253,16 @@ | |||
extern NSString *const TKStateMachineIsImmutableException; | |||
|
|||
/** | |||
A Notification posted when the `terminated` state of a `TKStateMachine` changes to YES | |||
*/ | |||
extern NSString *const TKStateMachineDidChangeStateNotification; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be TKStateMachineDidTerminateNotification
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes indeed.
I did some more thinking on this: Couldn't the
that introspects the transitions from the state to determine if it is indeed terminal. From there, we can emit the terminated error by evaluating if I would probably also add the |
This wouldn't work in the face of events with |
I wonder if this doesn't argue for eliminating the support for |
I would like to revive this terminal state work for TransitionKit 3.0 by removing support for |
The idea of nested machines is a good one and I would love to revive this conversation, unless there's something easy I'm missing to accomplish that another way. @blakewatters, is this something you're still considering? |
This patch adds the ability to specify terminal states for the machine. Once the machine transitions into a terminal state it will refuse to fire any more events. Patch also includes assorted other fixes (like eliminating the use of property setters in -init and transitioning off of shouldBeNil/shouldNotBeNil which are deprecated in Kiwi).