Hex Core JS
    Preparing search index...

    Function useDFA

    • A hook for simulating a deterministic finite automaton (DFA). This hook should be considered an "under the hood" version. For straighforward usage, the useReactiveDFA hook should be preferred. But for most practical purposes use the the useObservableDFA hook.

      Type Parameters

      • Status extends string
      • Signal extends string

      Parameters

      • initialStatus: Status

        The initial state for the the automaton.

      • statusMap: StatusMap<Status, Signal>

        An object defining the automaton.

      • strict: boolean = true

        A flag indicating whether bad signals should throw an error or silently ignored.

      Returns DFAState<Status, Signal>

      a tuple with a ref to the current state, and a transition function taking signals and returning the next state (or the current state if not in strict mode and received a bad signal).