TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | BSD 3.0 |
ReleasedLast Release | Mar 2015 |
Maintained by Alberto De Bortoli.
A proper thread-safe state machine for Objective-C.
Simple usage:
pod "ADBStateMachine"
to your PodfileADBStateMachine.h
in your classself.stateMachine = [[ADBStateMachine alloc] initWithInitialState:@"Idle" callbackQueue:nil];
ADBStateMachineTransition *t1 = [[ADBStateMachineTransition alloc] initWithEvent:@"start"
fromState:@"Idle"
toState:@"Started"
preBlock:^{
NSLog(@"Gonna move from Idle to Started!");
}
postBlock:^{
NSLog(@"Just moved from Idle to Started!");
}];
ADBStateMachineTransition *t2 = [[ADBStateMachineTransition alloc] initWithEvent:@"pause"
fromState:@"Started"
toState:@"Idle"
preBlock:nil
postBlock:nil];
[stateMachine addTransition:t1];
[stateMachine addTransition:t2];
[stateMachine processEvent:@"start"];
[stateMachine processEvent:@"pause"];