new Transaction(doc, origin, local)
Parameters:
| Name | Type | Description |
|---|---|---|
doc |
Doc | |
origin |
any | |
local |
boolean |
Example
const map = y.define('map', YMap)
// Log content when change is triggered
map.observe(() => {
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(() => {
map.set('a', 1)
map.set('b', 1)
}) // => "change triggered"
Classes
Members
-
_mergeStructs :Array.<AbstractStruct>
-
-
afterState :Map.<Number, Number>
-
Holds the state after the transaction.
-
beforeState :Map.<Number, Number>
-
Holds the state before the transaction started.
-
changed :Map.<AbstractType.<YEvent>, Set.<(String|null)>>
-
All types that were directly modified (property added or child inserted/deleted). New types are not included in this Set. Maps from type to parentSubs (
item.parentSub = nullfor YArray) -
changedParentTypes :Map.<AbstractType.<YEvent>, Array.<YEvent>>
-
Stores the events for the types that observe also child elements. It is mainly used by
observeDeep. -
deleteSet :DeleteSet
-
Describes the set of deleted items by ids
-
doc :Doc
-
The Yjs instance.
-
local :boolean
-
Whether this change originates from this doc.
-
meta :Map.<any, any>
-
Stores meta information on the transaction
-
origin :any
-