-
Notifications
You must be signed in to change notification settings - Fork 768
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
Expose internal transitions #376
base: dev
Are you sure you want to change the base?
Expose internal transitions #376
Conversation
…/dev Release 5.1.0
…/dev Release 5.1.1
…/dev Update Stateless.csproj
…/dev Update Stateless.csproj
…/dev Release 5.1.2
I agree, we should have a callback for the internal transitions. I am of two minds with regards to how it should be implemented. I am torn between what feels right, and what has the least amount of breakage.
Adding a new callback would cause no breakage, but I'm a bit wary. What if someone comes along and asks for Self transition callback, there's already one for internal and one for external. It would make sense to add that as well... I feel the right way to do it is increase the version number to 6 (then we can also drop netstandard1.x support), change the code so that all 3 transition types uses the one callback. |
I agree, if we want to go the single source route a major version bump makes sense because this is behavior changing. Alternatively, if we wanted to preserve behavior but without the need for a major bump, we could overload OnTransitioned with maybe a filter parameter to preserve the default behavior. For example something like,
This preserves the single api, while adding some config for the user. Thoughts? |
I think adding an overload with filtering is good option. I'm of two minds, really. But I should probably think of how it will be used, not how much more work we are adding to the project? |
/// <param name="onInternalTransitionAction"> | ||
/// The action to execute, accepting the details of the transition | ||
/// </param> | ||
public void OnTransitionedInternal(Action<Transition> onInternalTransitionAction) |
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.
if this is now a public method, I would be inclined to drop the internal
keyword
public void OnTransitionedInternal(Action<Transition> onInternalTransitionAction) | |
public void OnTransitioned(Action<Transition> onTransitionAction) |
TODO:
Motivation
In one of my projects I use System.Reactive to drive parts of the state machine. I find InternalTransitions useful for a bunch of discrete steps you'd like fine-grained control on, but that do not represent a super state. I noticed in the current implementation these transitions are not exposed to the OnTransitioned handler, which I find reasonable as they do not represent a transition.
However, it would be useful to expose them in a way so that you could use RX to drive the state machine using internal transitions as well as normal transitions.
Design Choices
OnTransitioned
method, I think it would be appropriate in this case to add a new api,OnTransitionedInternal
which is seperate. The reasoning is this sort of change would change the behavior, and break downstream dependencies, which warrants a different API/Event handler all together.Alternatively, we could add a new constructor parameter, and check a flag to include internal transitions in the original event. However, I feel the current implementation of the constructor is simple and I am hesitant to add more bloat to the constructor. And as for the original intent, RX.Net can easily merge such streams if someone for example needed all events in a single stream.