Skip to content
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

QUESTION why ther is no method like FireIfCan? #615

Open
Prikalel opened this issue Jan 21, 2025 · 0 comments
Open

QUESTION why ther is no method like FireIfCan? #615

Prikalel opened this issue Jan 21, 2025 · 0 comments

Comments

@Prikalel
Copy link

Prikalel commented Jan 21, 2025

Thats why I need to manually add code like this:

using Stateless;

/// <summary>
/// Методы расширения машины состояний.
/// </summary>
public static class StateMachineExtensions {
    /// <summary>
    /// Проверить что можно выполнить переход и сделать его.
    /// </summary>
    /// <param name="machine">Объект машины состояний.</param>
    /// <param name="trigger">Переход.</param>
    /// <returns>TRUE если переход произошёл.</returns>
    public static bool FireIfCan<TState, TTrigger>(this StateMachine<TState, TTrigger> machine, TTrigger trigger)
    {
        if (machine.CanFire(trigger)) {
            machine.Fire(trigger);
            return true;
        }
        return false;
    }
}

Cant understand that was stopping factor from adding the same extension to the library itself, seems weird to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant