GitHub

Reference machines

switchMachine

interface 2 type 3 function 1
interface Interfaces 2

# CreateSwitchInput

Members

disabled?
optional disabled?: boolean

Construct the machine in the disabled state. Defaults to false.

initial?
optional initial?: boolean

Initial checked value. Defaults to false.

# SwitchContext

Members

checked
checked: boolean

Whether the switch is currently on. Mirrored as aria-checked.

toggles
toggles: number

Number of user-initiated toggles since construction.

type Type Aliases 3

# SwitchEvent

SwitchEvent = { type: "TOGGLE"; } | { checked: boolean; type: "SET"; } | { type: "DISABLE"; } | { type: "ENABLE"; }

All events the Switch machine can receive.

function Functions 1

# createSwitchMachine ( )

createSwitchMachine(input?): SwitchMachine

Construct a fresh Switch machine.

Parameters

input?
CreateSwitchInput = {}

Returns

SwitchMachine