@hyperfrontend/state-machine/selectors

selectors

Predicate functions for querying async-process state out of a Store snapshot.

notStarted, inProgress, done, successful, failed, retrying, restarting, halted, paused, and cancelled answer single-question predicates over a process state. derivedState returns the canonical phase string for a process so UI code can render a single source-of-truth label instead of testing each predicate. All selectors are pure and work over any state slice that conforms to the async-process shape; they are not tied to a specific store instance.

API Reference§

● Variables

§type

cancelled

Selector that checks if operation was cancelled.
Example

Checking if cancelled

cancelled({ inProgress: false, success: false, fail: false, halt: true })
// => true
§type

derivedState

Derives a complete state object from the base state.
Example

Deriving complete state

const state = { inProgress: true, success: false, fail: false, halt: false }
derivedState(state)
// => { notStarted: false, inProgress: true, done: false, ... }
§type

done

Selector that checks if operation is done (success or fail).
Example

Checking if done

done({ inProgress: false, success: true, fail: false, halt: false })
// => true
§type

failed

Selector that checks if operation failed.
Example

Checking if failed

failed({ inProgress: false, success: false, fail: true, halt: false })
// => true
§type

halted

Selector that checks if operation is halted.
Example

Checking if halted

halted({ inProgress: false, success: false, fail: false, halt: true })
// => true
§type

inProgress

Selector that checks if operation is in progress.
Example

Checking if in progress

inProgress({ inProgress: true, success: false, fail: false, halt: false })
// => true
§type

notStarted

Selector that checks if operation has not started.
Example

Checking if not started

notStarted({ inProgress: false, success: false, fail: false, halt: false })
// => true
§type

paused

Selector that checks if operation is paused.
Example

Checking if paused

paused({ inProgress: true, success: false, fail: false, halt: true })
// => true
§type

restarting

Selector that checks if operation is restarting after success.
Example

Checking if restarting

restarting({ inProgress: true, success: true, fail: false, halt: false })
// => true
§type

retrying

Selector that checks if operation is retrying after failure.
Example

Checking if retrying

retrying({ inProgress: true, success: false, fail: true, halt: false })
// => true
§type

successful

Selector that checks if operation completed successfully.
Example

Checking if successful

successful({ inProgress: false, success: true, fail: false, halt: false })
// => true