View Source Yex.Sync.SharedDoc (y_ex v0.5.1)

This process handles messages for yjs protocol sync and awareness. https://github.com/yjs/y-protocols

Persistence is supported by passing persistence module. see Yex.Sync.SharedDoc.PersistenceBehaviour

If the observer process does not exist, it will automatically terminate.

Summary

Types

Launch Parameters

Functions

Returns a specification to start this module under a supervisor.

Receive doc update notifications in the calling process.

Send a message to the SharedDoc process. message mus be represented in the Yjs protocol default format. type supports sync and awareness.

Start the SharedDoc process.

Start the SharedDoc process with a link.

Start the initial state exchange.

Stop receiving doc update notifications in the calling process.

Types

@type launch_param() ::
  {:doc_name, String.t()}
  | {:persistence, {module() | {module(), init_arg :: term()}}}
  | {:auto_exit, boolean()}
  | {:doc_option, Yex.Doc.Options.t()}

Launch Parameters

  • :doc_name - The name of the document.
  • :persistence - Persistence module that implements PersistenceBehaviour.
  • :auto_exit - Automatically terminate the SharedDoc process when there is no longer a process to receive update notifications.
  • :doc_option - Options for the document.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Receive doc update notifications in the calling process.

Link to this function

send_yjs_message(server, message)

View Source

Send a message to the SharedDoc process. message mus be represented in the Yjs protocol default format. type supports sync and awareness.

Link to this function

start(param, option \\ [])

View Source
@spec start(param :: [launch_param()], option :: GenServer.options()) ::
  GenServer.on_start()

Start the SharedDoc process.

Link to this function

start_link(param, option \\ [])

View Source
@spec start_link(param :: [launch_param()], option :: GenServer.options()) ::
  GenServer.on_start()

Start the SharedDoc process with a link.

Link to this function

start_sync(server, step1_message)

View Source

Start the initial state exchange.

Stop receiving doc update notifications in the calling process.

If auto_exit is started with true(default), the SharedDoc process will automatically stop when there is no longer a process to receive update notifications.