# `Hologram.Component`
[🔗](https://github.com/bartblast/hologram/blob/v0.8.3/lib/hologram/component.ex#L1)

# `t`

```elixir
@type t() :: %Hologram.Component{
  emitted_context:
    %{required(atom()) =&gt; any()} | %{required({module(), atom()}) =&gt; any()},
  next_action: Hologram.Component.Action.t() | nil,
  next_command: Hologram.Component.Command.t() | nil,
  next_page: module() | {module(), keyword()},
  state: %{required(atom()) =&gt; any()}
}
```

# `init`

```elixir
@callback init(%{required(atom()) =&gt; any()}, t(), Hologram.Server.t()) ::
  {t(), Hologram.Server.t()} | t() | Hologram.Server.t()
```

Initializes component and server structs (when run on the server).

# `template`

```elixir
@callback template() :: (map() -&gt; list())
```

Returns a template in the form of an anonymous function that given variable bindings returns a DOM.

# `colocated_template_path`

```elixir
@spec colocated_template_path(String.t()) :: String.t()
```

Resolves the colocated template path for the given component module given its file path.

# `maybe_build_colocated_template_clause`

```elixir
@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.

# `maybe_register_colocated_template_markup`

```elixir
@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.

# `prop`
*macro* 

```elixir
@spec prop(atom(), atom(), Hologram.Commons.Types.opts()) :: Macro.t()
```

Accumulates the given property definition in __props__ module attribute.

# `put_action`

```elixir
@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).

# `put_action`

```elixir
@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).

# `put_command`

```elixir
@spec put_command(t(), atom() | keyword()) :: t()
```

Puts the given command spec to the component's next_command field.
Next command will be sent asynchronously to the server.

# `put_command`

```elixir
@spec put_command(t(), atom(), keyword()) :: t()
```

Puts the given command spec to the component's next_command field.
Next command will be sent asynchronously to the server.

# `put_context`

```elixir
@spec put_context(t(), any(), any()) :: t()
```

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.

# `put_page`

```elixir
@spec put_page(t(), module()) :: t()
```

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.

# `put_page`

```elixir
@spec put_page(t(), module(), keyword()) :: t()
```

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.

# `put_state`

```elixir
@spec put_state(t(), keyword() | map()) :: t()
```

Puts the given key-value entries to the component state.

# `put_state`

```elixir
@spec put_state(t(), atom() | [atom()], any()) :: t()
```

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.

# `register_props_accumulator`

```elixir
@spec register_props_accumulator() :: Hologram.Compiler.AST.t()
```

Returns the AST of code that registers __props__ module attribute.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
