View Source LiveAssign (live_assign v0.3.0)

Conventions for managing state of LiveViews and LiveComponents.

See the README for another overview and some examples.

Here are the core concepts – many of which are shared across both LiveViews and LiveComponents.

props

Props

Supported by LiveAssign.LiveComponent.

Props are a one-way street: they are assigns that can only be passed in to a component, and are not modified internally beyond that. Props can be required by the component, or made optional with a default value. Reactive functions can be triggered by prop changes.

See LiveAssign.LiveComponent.prop/2 for details.

slots

Slots

Supported by LiveAssign.LiveComponent.

LiveComponent slots are represented as "slot props". They may be required or optional.

See LiveAssign.LiveComponent.slot/2 for details.

state

State

Supported by LiveAssign.LiveView and LiveAssign.LiveComponent.

State is used to track internal LiveView and LiveComponent logic, and can be modified throughout their lifecycles. State can be initialized with default values. Reactive functions can be triggered by state changes.

See LiveAssign.LiveComponent.state/2 and LiveAssign.LiveView.state/2 for details.

reactive-functions

Reactive Functions

Supported by LiveAssign.LiveView and LiveAssign.LiveComponent.

Reactive functions are regular functions tagged with the @react attribute. They can be triggered by changes to props or state.

See LiveAssign.React for details.

configuration

Configuration

LiveAssign performs some validations at runtime to provide helpful error messages to developers. You may wish to disable these checks - for example, to improve performance in a production environment. That is possible with:

config :live_assign, runtime_checks?: false