Xenia.Provider (Xenia v0.1.1)

Copy Markdown View Source

Publishes application-wide values to Xenia adapters.

A provider renders a hidden element and wraps nothing, so it can sit anywhere on the page, typically once in the layout. When its value changes, LiveView patches the element and every adapter that consumes the provider receives the new value.

Example

<Xenia.Provider.provider name="theme" value={@theme} />

Adapters receive these values by declaring:

consumes: ["theme"]

The XeniaProvider hook must be registered, which createHooks/1 does.

Summary

Functions

Renders a hidden element that publishes value under name.

Functions

provider(assigns)

Renders a hidden element that publishes value under name.

Attributes

  • name (:string) (required) - Name of the shared provider, e.g. theme or locale.
  • value (:any) (required) - A JSON-serializable application-wide value.
  • id (:string) - DOM id. Defaults to "xenia-provider-<name>". Defaults to nil.