Summary
Callbacks
Handles a client-side action, typically triggered by a user interaction.
Handles a server-side command dispatched from the client.
Initializes the component struct on the client.
Initializes the component and server structs on the server.
Returns a template in the form of an anonymous function that given variable bindings returns a DOM.
Functions
Resolves the colocated template path for the given component module given its file path.
Removes the subscription on channel for the current handler's component.
Builds the template clause for colocated template if markup is registered in module attribute. Returns nil if no colocated template is found.
Registers colocated template markup in a module attribute if the template file exists. Returns nil if the template file doesn't exist.
Accumulates the given property definition in props module attribute.
Puts the given action spec to the component or server struct's next_action field. Next action will be executed by the client-side runtime after the specified delay (in milliseconds, defaults to 0).
Puts the given action spec to the component or server struct's next_action field. Next action will be executed by the client-side runtime after the specified delay (in milliseconds, defaults to 0).
Queues an action broadcast to subscribers of channel.
Queues an action broadcast to subscribers of channel with the given params.
See put_broadcast/3 for delivery semantics.
Queues an action broadcast that excludes one or more identities from delivery.
Like put_broadcast_except/4 but with explicit params.
Puts the given command spec to the component's next_command field. Next command will be sent asynchronously to the server.
Puts the given command spec to the component's next_command field. Next command will be sent asynchronously to the server.
Puts the given key-value pair to the component's emitted_context field. Context emitted by a component is available to all of its child nodes.
Puts the given page module to the component's next_page field. The client will navigate to this page asynchronously after the current action finished executing.
Puts the given page module and params to the component's next_page field (as a tuple). The client will navigate to this page asynchronously after the current action finished executing.
Puts the given key-value entries to the component state.
If the second arg is a list of keys representing a component state path it puts the value in the nested component state path, otherwise it puts the given key-value pair to the component state.
Subscribes the current handler's component to channel.
Returns the AST of code that registers props module attribute.
Types
@type t() :: %Hologram.Component{ emitted_context: %{required(atom()) => any()} | %{required({module(), atom()}) => any()}, next_action: Hologram.Component.Action.t() | nil, next_command: Hologram.Component.Command.t() | nil, next_page: module() | {module(), keyword()}, state: %{required(atom()) => any()} }
Callbacks
Handles a client-side action, typically triggered by a user interaction.
@callback command(atom(), %{required(atom()) => any()}, Hologram.Server.t()) :: Hologram.Server.t()
Handles a server-side command dispatched from the client.
Initializes the component struct on the client.
@callback init(%{required(atom()) => any()}, t(), Hologram.Server.t()) :: {t(), Hologram.Server.t()} | t() | Hologram.Server.t()
Initializes the component and server structs on the server.
Returns a template in the form of an anonymous function that given variable bindings returns a DOM.
Functions
Resolves the colocated template path for the given component module given its file path.
@spec delete_subscription(Hologram.Server.t(), atom() | tuple()) :: Hologram.Server.t()
Removes the subscription on channel for the current handler's component.
The subscription is scoped to the component whose handler is running - the page in a page handler, the layout in a layout handler, or the component in a component handler. Takes effect after the handler returns successfully; if the handler raises, it is discarded along with the rest of the changes.
Idempotent: removing a channel that is not subscribed is a no-op.
@spec maybe_build_colocated_template_clause(Macro.Env.t(), module()) :: Hologram.Compiler.AST.t()
Builds the template clause for colocated template if markup is registered in module attribute. Returns nil if no colocated template is found.
@spec maybe_register_colocated_template_markup(String.t()) :: Hologram.Compiler.AST.t() | nil
Registers colocated template markup in a module attribute if the template file exists. Returns nil if the template file doesn't exist.
Accumulates the given property definition in props module attribute.
@spec put_action(t() | Hologram.Server.t(), atom() | keyword()) :: t() | Hologram.Server.t()
Puts the given action spec to the component or server struct's next_action field. Next action will be executed by the client-side runtime after the specified delay (in milliseconds, defaults to 0).
@spec put_action(t() | Hologram.Server.t(), atom(), keyword() | map()) :: t() | Hologram.Server.t()
Puts the given action spec to the component or server struct's next_action field. Next action will be executed by the client-side runtime after the specified delay (in milliseconds, defaults to 0).
@spec put_broadcast(Hologram.Server.t(), atom() | tuple(), atom()) :: Hologram.Server.t()
Queues an action broadcast to subscribers of channel.
Sent after the handler returns successfully; if the handler raises, it is
discarded along with the rest of the changes. Delivered to every cid that
subscribed to the channel via put_subscription on each receiving connection.
@spec put_broadcast(Hologram.Server.t(), atom() | tuple(), atom(), keyword() | map()) :: Hologram.Server.t()
Queues an action broadcast to subscribers of channel with the given params.
See put_broadcast/3 for delivery semantics.
@spec put_broadcast_except( Hologram.Server.t(), Hologram.Server.Broadcast.identity() | [Hologram.Server.Broadcast.identity()], atom() | tuple(), atom() ) :: Hologram.Server.t()
Queues an action broadcast that excludes one or more identities from delivery.
Like put_broadcast/3 but takes an except argument naming identities
({:instance, id}, {:session, id}, {:user, id}) that should not receive
the broadcast. except accepts either a single identity tuple or a list of
identity tuples.
@spec put_broadcast_except( Hologram.Server.t(), Hologram.Server.Broadcast.identity() | [Hologram.Server.Broadcast.identity()], atom() | tuple(), atom(), keyword() | map() ) :: Hologram.Server.t()
Like put_broadcast_except/4 but with explicit params.
Puts the given command spec to the component's next_command field. Next command will be sent asynchronously to the server.
Puts the given command spec to the component's next_command field. Next command will be sent asynchronously to the server.
Puts the given key-value pair to the component's emitted_context field. Context emitted by a component is available to all of its child nodes.
Puts the given page module to the component's next_page field. The client will navigate to this page asynchronously after the current action finished executing.
Puts the given page module and params to the component's next_page field (as a tuple). The client will navigate to this page asynchronously after the current action finished executing.
Puts the given key-value entries to the component state.
If the second arg is a list of keys representing a component state path it puts the value in the nested component state path, otherwise it puts the given key-value pair to the component state.
@spec put_subscription(Hologram.Server.t(), atom() | tuple()) :: Hologram.Server.t()
Subscribes the current handler's component to channel.
The subscription is scoped to the component whose handler is running - the page in a page handler, the layout in a layout handler, or the component in a component handler. Once subscribed, the component receives actions broadcast on the channel. Takes effect after the handler returns successfully; if the handler raises, it is discarded along with the rest of the changes.
Idempotent: subscribing to the same channel twice does not duplicate it.
@spec register_props_accumulator() :: Hologram.Compiler.AST.t()
Returns the AST of code that registers props module attribute.