Comments (6)
This is due to change made in #544. State is no longer re-entered unless the trigger is explicitly configured via PermitReentry
. PermitDynamic
is also affected due to this.
However, if config.PermitReentry(Trigger.Info);
is added to above test configuration, the state machine throws InvalidOperationException
-
System.InvalidOperationException: 'Multiple permitted exit transitions are configured from state 'Ready' for trigger 'Info'. Guard clauses must be mutually exclusive.'
It appears that it is no longer possible to re-enter a state dynamically, which I believe is a regression.
@mclift , @crozone , @HenningNT Could you take a look?
from stateless.
Thanks for raising this, @Fieslix & @DeepakParamkusam.
As I see it, allowing state re-entry through a dynamic transition should never have been the default behavior as it's inconsistent with the non-dynamic transitions and makes the API confusing. I also agree that there should be a way to allow a dynamic transition to re-enter the source state.
As PermitDynamic
and PermitDynamicIf
already have 20+ method signatures between them, perhaps an additional parameter with a default value would be appropriate here.
To represent this internally, perhaps there's an argument for replacing the ReentryTriggerBehaviour
class with a property on TriggerBehaviour
that sets whether reentry is enabled in instances of its implementations.
So we might end up with something like:
config.PermitDynamic(Trigger.X, () => State.A, permitReentry: true);
How does this sound as an approach?
from stateless.
This is a difficult design decision.
I see Exception handling as another problem, because you don't know if PermitDynamic
will try to re-enter the state on creation of the state machine.
Just to make that clear, I'm okay with not reentering the state, but I would expect the Action to execute.
Why would I have that transition, just to ignore it.
Okay, It's called the on entry from action, but then again I would expect a way to attach an action to that dynamic self transition.
from stateless.
It's been a while since this was opened and there's been less discussion on the subject that I thought there might be.
As I've thought about it more, my opinion has changed toward restoring the original behaviour (allow re-entry), and to make it clear in the xmldoc that this aspect of dynamic transitions differs from their "static" counterparts. This has been driven by a few things: the fact that PermitReentry
is distinct from Permit
for the static transition configs; the risk to users of Stateless of regressions being introduced by this change in behaviour; and a reluctance to increase the complexity of the API by adding extra configuration to control reentry behaviour. I'm not sure if that last one is justified.
In any case, the test coverage around state reentry is clearly in need to improvement.
I'll try to get a PR out in the next couple of weeks unless someone else beats me to it, and I'm very interested to hear folks' opinions on this in the meantime.
from stateless.
While looking into this, I think there is a decent change this issue is not present when using FireAsync
.
Which probably means, the issue in #544 is still present inside the Async implementation.
from stateless.
@Fieslix thank you. I've updated the PR to addess issues #543 and #565 in the FireAsync
implementation, plus unit tests.
from stateless.
Related Issues (20)
- Async EntryActionBehaviour throws InvalidOperationException
- OnEntry does not get fired in a WinForms app HOT 3
- Add Direct License Information In Nuget metadata HOT 5
- RobiniaDocs API Explorer
- Is it possible to change the registered delegation method to event? HOT 2
- Using PermitIf on a state with substates seems to lead to reentry HOT 8
- Internal state transitions incorrectly list Entry actions in DOT graph export HOT 1
- Intermittent test failure in `LoseSyncContext()` HOT 1
- Handling of value based trigger parameters
- Add NuGet package README
- How To Use dynamic Stateless HOT 5
- [Questions] Queue implementation? HOT 3
- Remove dependency from dirgraph format HOT 2
- Add Chinese readme HOT 3
- Reconfigure a state
- Execute guards in parallel? HOT 3
- Mermaid graph support
- Unexpected graph labels for internal transitions HOT 1
- Graph: re-entry transition is missing its entry action HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stateless.