AshBackendDrivenOptimisticUi.PushId (AshBackendDrivenOptimisticUi v0.1.0)

Copy Markdown View Source

The id of an optimistic push, computed from the record as it was before the write: <type>:<record id>:<updated_at>:<event>:<label>.

label is the optimistic action name for a push made inside optimistic, and the answered event's name for a push made inside on. The record's updated_at moves on every write, so the next write's ids are new by themselves and nothing has to be remembered.

The server computes the id with for/3 both when the client shows the push at once (through the record's ctx.push_ids, see for_record/1) and when the notifier really sends it, so the two match by construction.

An optimistic rule of a create or generic action has no record before the write, so its pushes get no id.

Summary

Functions

The {event, label} of every push resource declares that has a record before the write.

The id of event pushed under label by a write to record, as record is now.

Every declared push id of record: %{event => %{label => id}}.

Whether the pushes of optimistic action carry an id: its record exists before the write.

The JSON Logic variable path the compiled push reads its id from.

Functions

declared(resource)

@spec declared(Ash.Resource.t()) :: [{atom(), atom()}]

The {event, label} of every push resource declares that has a record before the write.

for(map, event, label)

@spec for(struct(), atom(), atom()) :: String.t()

The id of event pushed under label by a write to record, as record is now.

for_record(record)

@spec for_record(struct()) :: %{required(atom()) => %{required(atom()) => String.t()}}

Every declared push id of record: %{event => %{label => id}}.

identified?(resource, action)

@spec identified?(Ash.Resource.t(), atom()) :: boolean()

Whether the pushes of optimistic action carry an id: its record exists before the write.

variable(event, label)

@spec variable(atom(), atom()) :: String.t()

The JSON Logic variable path the compiled push reads its id from.