Macaw.Frame.Requests (macaw_frame v0.1.0)

Copy Markdown View Source

What a slot asks of its request (spec/05 §3): its order, whether the window reaches it, and how its rows may be reduced. The host builds the request (macaw spec/06 §3.5): its params from the binding, its window from window, its budget from budget/4 under the ceiling; the Frame says only these. Copied from visualize's Visualize.Board.Budget.reducer/2; its board-wide feed_reducers/2 and the board's window resolution (Visualize.Board.window/2) are the host's here.

  • Order (order/3, §3.1): a slot whose layer's steps begin with a sort followed by a take asks for that order, its field as a role, [{{:role, field}, direction}], so a delivery capped at the budget holds the rows the layer shows. A take of the first rows (side: :start) asks the sort's direction, a take of the last rows its reverse. Two layers on one slot asking different orders answer the first layer's in document order; any other slot answers [], the source's own order.
  • The window (windowed?/1, §3.2) is state, never the Frame's: a slot whose source's schema has a :time window field carries the surface's window in its request, any other ignores it. The Frame reads the window only as its deliveries carry it (served.window).
  • The reducer (reducer/4, reducer/5, §3.3), the most demanding layer deciding: :none when any layer reads the slot whole, {"m4", w} when any layer is continuous (w the widest such layer's plot width in device pixel columns), else nil, the host's default ("lttb").

Each answers every input: settings whose document does not compile, and a slot no layer reads, answer [], false or nil.

Summary

Functions

The order a slot asks for (§3.1): [{{:role, field}, :asc | :desc}] for a layer whose steps begin with a sort then a take, the first such layer in document order; [] otherwise. Read from the document alone, at no size.

How a slot's rows may be reduced at size, in CSS pixels (§3.3): :none, {"m4", w} or nil.

How a slot's rows may be reduced at size in context (§3.3, §2.5): as reducer/4, w counted in device pixel columns by context.ratio. A number in place of the context is the ratio.

The slots a layer of the settings' document reads (§3), each once: what a host asks order/2, budget/4 and reducer/4 for.

Whether the surface's window reaches a slot bound to a source of schema (§3.2): its window field is a :time field. A schema with a :number or :point window field, or none, ignores window until the standard window is widened (spec/01 §9).

Functions

order(slot, arg2, registry)

@spec order(term(), term(), map()) :: Macaw.Component.order()

The order a slot asks for (§3.1): [{{:role, field}, :asc | :desc}] for a layer whose steps begin with a sort then a take, the first such layer in document order; [] otherwise. Read from the document alone, at no size.

reducer(slot, settings, size, registry)

@spec reducer(term(), term(), term(), map()) :: Macaw.Component.reducer()

How a slot's rows may be reduced at size, in CSS pixels (§3.3): :none, {"m4", w} or nil.

reducer(slot, settings, size, context_or_ratio, registry)

@spec reducer(term(), term(), term(), term(), map()) :: Macaw.Component.reducer()

How a slot's rows may be reduced at size in context (§3.3, §2.5): as reducer/4, w counted in device pixel columns by context.ratio. A number in place of the context is the ratio.

slots(settings, registry)

@spec slots(term(), map()) :: [String.t()]

The slots a layer of the settings' document reads (§3), each once: what a host asks order/2, budget/4 and reducer/4 for.

windowed?(schema)

@spec windowed?(term()) :: boolean()

Whether the surface's window reaches a slot bound to a source of schema (§3.2): its window field is a :time field. A schema with a :number or :point window field, or none, ignores window until the standard window is widened (spec/01 §9).

iex> schema = Macaw.Data.Schema.new!(%{t: %{type: :time, window: true}})
iex> {Macaw.Frame.Requests.windowed?(schema), Macaw.Frame.Requests.windowed?(nil)}
{true, false}