Provides subscription functionality for monitoring changes in shared types. This module implements features for observing changes in documents and other shared types, and receiving notifications when changes occur.
Features
- Monitor change events in shared types
- Process-level subscription management
- Prevention of automatic resource release
- Simple unsubscribe functionality
Usage
Subscriptions are typically created by monitoring functions like Yex.Doc.monitor_update/2
or Yex.SharedType.observe/2 and are used to receive change notifications:
iex> doc = Yex.Doc.new()
iex> {:ok, ref} = Yex.Doc.monitor_update(doc)
iex> # Monitor changes...
iex> Yex.Subscription.unsubscribe(ref) # Unsubscribe from monitoring
:ok
Summary
Functions
Registers a subscription and returns a reference. This function stores the subscription in the process dictionary to prevent automatic release by the garbage collector.
Unsubscribes from a subscription. Removes the subscription associated with the given reference from the process dictionary and cleans up resources.
Types
Functions
Registers a subscription and returns a reference. This function stores the subscription in the process dictionary to prevent automatic release by the garbage collector.
Parameters
sub- The subscription to registerref- Optional reference. If not provided, a new reference will be generated
Returns
- The subscription reference
Unsubscribes from a subscription. Removes the subscription associated with the given reference from the process dictionary and cleans up resources.
Parameters
ref- The reference of the subscription to unsubscribe
Returns
:ok- If unsubscription was successful