Transaction
A transaction is created for every change on the Yjs model. It is possible to bundle changes on the Yjs model in a single transaction to minimize the number on messages sent and the number of observer calls. If possible the user of this library should bundle as many changes as possible. Here is an example to illustrate the advantages of bundling:
Example:
const map = y.define('map', YMap)
// Log content when change is triggered
map.observe(function () {
console.log('change triggered')
})
// Each change on the map type triggers a log message:
map.set('a', 0) // => "change triggered"
map.set('b', 0) // => "change triggered"
// When put in a transaction, it will trigger the log after the transaction:
y.transact(function () {
map.set('a', 1)
map.set('b', 1)
}) // => "change triggered"
Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public |
Saves the old state set of the Yjs instance. |
|
public |
changedParentTypes: Map<YType, Array<YEvent>> Stores the events for the types that observe also child elements. |
|
public |
changedTypes: Set<YType, String> All types that were directly modified (property added or child inserted/deleted). |
|
public |
Set of all deleted Types and Structs. |
|
public |
All new types that are added during a transaction. |
|
public |
|
Public Constructors
public constructor() source
Public Members
public beforeState: Map<Number, Number> source
Saves the old state set of the Yjs instance. If a state was modified, the original value is saved here.
public changedParentTypes: Map<YType, Array<YEvent>> source
Stores the events for the types that observe also child elements.
It is mainly used by observeDeep
.