Yex.SharedType (y_ex v0.10.5)
View SourceThe SharedType protocol defines the behavior of shared types in Yex. This module provides functionality for observing changes to shared types, including arrays, maps, text, and XML nodes.
Summary
Functions
Registers a change observer that will be message every time this shared type is modified.
Registers a change observer that will be message every time this shared type or any of its children is modified.
Unobserve the shared type for changes. Removes the observer registered with the given reference.
Unobserve the shared type and its children for changes. Removes the deep observer registered with the given reference.
Types
Functions
Registers a change observer that will be message every time this shared type is modified.
If the shared type changes, a message is delivered to the monitoring process in the shape of:
{:observe_event, ref, event, origin, metadata}where:
refis a monitor reference returned by this function;eventis a struct that describes the change;originis the origin passed to theYex.Doc.transaction()function.metadatais the metadata passed to theobservefunction.
Options
:metadata- provides metadata to be attached to this observe.
Returns
- A reference that can be used to unsubscribe the observer
Registers a change observer that will be message every time this shared type or any of its children is modified.
If the shared type changes, a message is delivered to the monitoring process in the shape of:
{:observe_deep_event, ref, events, origin, metadata}where:
refis a monitor reference returned by this function;eventsis a list of structs that describes the changes;originis the origin passed to theYex.Doc.transaction()function.metadatais the metadata passed to theobserve_deepfunction.
Options
:metadata- provides metadata to be attached to this observe.
Returns
- A reference that can be used to unsubscribe the deep observer
@spec unobserve(reference()) :: :ok
Unobserve the shared type for changes. Removes the observer registered with the given reference.
@spec unobserve_deep(reference()) :: :ok
Unobserve the shared type and its children for changes. Removes the deep observer registered with the given reference.