View Source Love (love_ex v0.2.0)

Conventions for the development 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 Love.Component.

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 Love.Component.prop/2 for details.

slots

Slots

Supported by Love.Component.

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

See Love.Component.slot/2 for details.

state

State

Supported by Love.View and Love.Component.

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 Love.Component.state/2 and Love.View.state/2 for details.

reactive-functions

Reactive Functions

Supported by Love.View and Love.Component.

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

See Love.React for details.

event-messages

Event Messages

Supported by Love.View and Love.Component.

Love unifies the sending and receiving of events between LiveView and LiveComponents with its Love.Events behaviour. Components can emit events to LiveViews or other LiveComponents using one standard callback in both module types: Love.Events.handle_message/4.

When writing a component, you no longer have to decide how its events are bubbled up to where they need to go. Just Love.Component.emit/3 and go.

Events can also be explicitly sent with Love.Events.send_message/4.

See Love.Component.event/1 and Love.Events for details.

configuration

Configuration

Love 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 :love_ex, runtime_checks?: false