View Source Hologram.Component behaviour (hologram v0.3.0)
Summary
Callbacks
Initializes component and server structs (when run 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.
Returns the AST of template/0 function definition that uses markup fetched from the give template file. If the given template file doesn't exist nil is returned.
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 runtime synchronously.
Puts the given action spec to the component or server struct's next_action field. Next action will be executed by the runtime synchronously.
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.
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
@callback init(%{required(atom()) => any()}, t(), Hologram.Server.t()) :: {t(), Hologram.Server.t()} | t() | Hologram.Server.t()
Initializes component and server structs (when run 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.
Returns the AST of template/0 function definition that uses markup fetched from the give template file. If the given template file doesn't exist nil is returned.
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 runtime synchronously.
@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 runtime synchronously.
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 register_props_accumulator() :: Hologram.Compiler.AST.t()
Returns the AST of code that registers props module attribute.