# `Chronicle.Projections.GlobalHandler`
[🔗](https://github.com/Cratis/Chronicle.Elixir/blob/main/lib/chronicle/projections/global_handler.ex#L4)

Macro for defining a mapping shared across every read model variant of a given identity,
without repeating it on each variant module.

A global handler is never registered as a projection on its own. Its `from/2` mappings are
merged into every read model or declarative projection whose `variant_of/2` names the same
identity, before that variant's own non-entering events are reclassified into update-only
joins - so a shared mapping for a non-entering event is turned into an update-only join
exactly like a mapping declared directly on the variant.

## Quick Example

    defmodule MyApp.Projections.WorkItemTitleHandler do
      use Chronicle.Projections.GlobalHandler, identity: MyApp.ReadModels.WorkItem

      from MyApp.Events.TitleChanged,
        set: [title: :title]
    end

A mapping that targets a member some variant lacks is a declaration error
(`Chronicle.Projections.GlobalHandlerPropertyNotOnVariant`), raised at registration time -
not a silently skipped mapping.

## Registering with Chronicle.Client

    {Chronicle.Client,
      ...
      global_handlers: [MyApp.Projections.WorkItemTitleHandler]}

Or use `otp_app:` auto-discovery - modules that export `__chronicle_global_handler__/1` are
discovered automatically.

# `from`
*macro* 

Declares how an event maps onto every variant of this handler's identity.

See `Chronicle.ReadModels.ReadModel` for full options documentation.

---

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