Git Product home page Git Product logo

Comments (6)

DeepakParamkusam avatar DeepakParamkusam commented on August 16, 2024

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.

mclift avatar mclift commented on August 16, 2024

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.

Fieslix avatar Fieslix commented on August 16, 2024

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.

mclift avatar mclift commented on August 16, 2024

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.

Fieslix avatar Fieslix commented on August 16, 2024

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.

mclift avatar mclift commented on August 16, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.