Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public |
|
|
public |
The AbstractConnector.that is used by this Yjs instance. |
|
public |
ds: * |
|
public |
os: * |
|
public |
The AbstractPersistence that is used by this Yjs instance. |
|
public |
The room name that this Yjs instance connects to. |
|
public |
share: {} |
|
public |
ss: * |
|
public |
userID: * |
Method Summary
Public Methods | ||
public |
Define a shared data type. |
|
public |
destroy() Disconnect from the room, and destroy all traces of this Yjs instance. |
|
public |
disconnect(): * Disconnect this Yjs Instance from the network. |
|
public |
Get a defined type. |
|
public |
reconnect(): * If disconnected, tell the connector to reconnect to the room. |
|
public |
Changes that happen inside of a transaction are bundled. |
|
public |
whenContentReady(): * |
Inherited Summary
From class NamedEventHandler | ||
public |
destroy() |
|
public |
Emit a named event. |
|
public |
off(name: *, f: *) Remove an event listener that was registered with either EventHandler#on or EventHandler#once. |
|
public |
Adds a named event listener. |
|
public |
Adds a named event listener. |
|
public |
when(name: *): * Returns a Promise that is resolved when the event name is called. |
Public Constructors
Public Members
public ds: * source
public os: * source
public persistence: AbstractPersistence source
The AbstractPersistence that is used by this Yjs instance.
public share: {} source
public ss: * source
public userID: * source
Public Methods
public define(name: String, TypeConstructor: YType Constructor): YType source
Define a shared data type.
Multiple calls of y.define(name, TypeConstructor)
yield the same result
and do not overwrite each other. I.e.
y.define(name, type) === y.define(name, type)
After this method is called, the type is also available on y.share[name]
.
Best Practices:
Either define all types right after the Yjs instance is created or always
use y.define(..)
when accessing a type.
Params:
Name | Type | Attribute | Description |
name | String | ||
TypeConstructor | YType Constructor | The constructor of the type definition |
Return:
YType | The created type |
Example:
// Option 1
const y = new Y(..)
y.define('myArray', YArray)
y.define('myMap', YMap)
// .. when accessing the type use y.share[name]
y.share.myArray.insert(..)
y.share.myMap.set(..)
// Option2
const y = new Y(..)
// .. when accessing the type use `y.define(..)`
y.define('myArray', YArray).insert(..)
y.define('myMap', YMap).set(..)
public destroy() source
Disconnect from the room, and destroy all traces of this Yjs instance. Persisted data will remain until removed by the persistence adapter.
Override:
NamedEventHandler#destroypublic disconnect(): * source
Disconnect this Yjs Instance from the network. The connector will unsubscribe from the room and document updates are not shared anymore.
Return:
* |
public get(name: String): * source
Get a defined type. The type must be defined locally. First define the type with define.
This returns the same value as y.share[name]
Params:
Name | Type | Attribute | Description |
name | String | The typename |
Return:
* |
public reconnect(): * source
If disconnected, tell the connector to reconnect to the room.
Return:
* |