ToggleFieldHandle

data class ToggleFieldHandle(val field: StateField<Boolean>, val toggle: StateEffectType<Unit>, val set: StateEffectType<Boolean>)

A handle grouping a StateField with its associated StateEffectTypes for a boolean toggle pattern.

Dispatch toggle with Unit to flip the value, or set with a specific Boolean to force it.

val (panelField, togglePanel, setPanel) = toggleField(default = false)

// Toggle:
session.dispatch(TransactionSpec(effects = listOf(togglePanel.of(Unit))))

// Force on:
session.dispatch(TransactionSpec(effects = listOf(setPanel.of(true))))

// Read:
val isOpen = state.field(panelField)

Constructors

Link copied to clipboard
constructor(field: StateField<Boolean>, toggle: StateEffectType<Unit>, set: StateEffectType<Boolean>)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard