# `Datumo.StateView`
[🔗](https://github.com/ortegacmanuel/datumo/blob/v0.1.0/lib/datumo/state_view.ex#L1)

Behaviour for read slices (read models), and the read that serves them.

Pick from history, fold into current state, project what the screen gets.
There is no table and no materialised projection: the view is computed on
every call, by `read/3`.

  * `query/1` — what to read, from the call's arguments.
  * `next_query/1` (optional) — what else to read, given what's folded so
    far: the plots of the receptions of a lot can't be named before the lot
    is read. It returns every follow-up query the state implies; `read/3`
    reads only the ones it hasn't read yet and stops when none are new.
  * `initial_state/0`, `apply_event/2` — the fold.
  * `project/2` (optional) — the read model, from the folded state and the
    call's arguments. Without it, the state is the read model.

# `apply_event`

```elixir
@callback apply_event(state :: term(), event :: map()) :: term()
```

# `initial_state`

```elixir
@callback initial_state() :: term()
```

# `next_query`
*optional* 

```elixir
@callback next_query(state :: term()) :: term() | nil
```

# `project`
*optional* 

```elixir
@callback project(state :: term(), args :: term()) :: term()
```

# `query`

```elixir
@callback query(args :: term()) :: term()
```

# `read`

# `view`

The read with the store passed in: `read_model.query(args)`, then `next_query/1`
until nothing new, the fold, and `project/2`. Returns `{view,
every_query_item_read}`. Production reads FACT; `Datumo.Scenario` reads the
scenario's `given`, so a test runs this same code.

---

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