You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-2Lines changed: 14 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,7 +133,19 @@ You can pass in an action and the name of an active state to add this action to
133
133
134
134
135
135
### Getting notified on state changes
136
-
Work in progress, coming soon
136
+
You can create an observer that is notified whenever the state machine changes its state. To do that, you have to create your observer implementing the IStateChangeOberser interface. This interface's method is called on every state change, you can do whatever you like in this function. Here's an example for such a class:
System.out.println("State has changed, new State is: "+ newState.getClass().getSimpleName());
144
+
}
145
+
};
146
+
```
147
+
148
+
To add a new observer to the state machine simply call `stateMachine.addStateChangeObserver(IStateChangeObserver observer)` passing in an instance of you observer class. In case an observer should no longer be notified on state changes, simply remove it by calling `stateMachine.removeStateChangeObserver(IStateChangeObserver observer)`.
137
149
138
150
139
151
## Usage
@@ -146,7 +158,7 @@ Releases can be found on the Maven Central repository. Just add this dependency
* Execute an abort command. Can be used to transition from all 'normal' and 'stopping'-states to Aborted. Alias for invokeTransition(TransitionName.abort).
112
+
* Execute an abort command. Can be used to transition from all 'normal' and 'stopping'-states to Aborted. Alias for
assertEquals(secondObserver.observedStateName, "CompleteState", "Second observer should not have been notified after removal and should still be in CompleteState");
0 commit comments