State

An entity that manages transitioning and exposing state to view's.

Type Signature

state Counter($value = 0) -> {
  mut increment -> $value++;
  mut decrement -> $value--;
}

Constructing state containers

Parameters provided to state containers witho no default values must be provided to use the state in a provider.

state Counter(value: number) -> { }

Exposing constructor values

The value of value will be made available as $value or on the alias directly as value.

state Counter($value: number) -> { }

Default constructor values

Constructor arguments can have default values provided.

state Counter(value = 0) -> { }

Mutate state values

Modify the values in your state purely with mutators.

Private state values

Simplify the interface of your state container by hiding internal values.

Getters to override or expose values

Omit Parentheses

When your signature or getter or mutator does not accept parameters, the parentheses can be omitted.

Last updated

Was this helpful?