change parameter order of transaction events
This commit is contained in:
parent
cd82de7742
commit
fa3c92f44c
@ -11,15 +11,22 @@ Yjs is **network agnostic** (p2p!), supports many existing **rich text editors**
|
|||||||
|
|
||||||
### Supported Editors:
|
### Supported Editors:
|
||||||
|
|
||||||
| Name | Cursors | Demo |
|
| Name | Cursors | Binding | Demo |
|
||||||
|---|:-:|---|
|
|---|:-:|---|---|
|
||||||
| [ProseMirror](https://prosemirror.net/) | ✔ | [link](https://yjs.website/tutorial-prosemirror.html) |
|
| [ProseMirror](https://prosemirror.net/) | ✔ | [y-prosemirror](http://github.com/y-js/y-prosemirror) | [link](https://yjs.website/tutorial-prosemirror.html) |
|
||||||
| [Quill](https://quilljs.com/) | | [link](https://yjs.website/tutorial-quill.html) |
|
| [Quill](https://quilljs.com/) | | [y-quill](http://github.com/y-js/y-quill) | [link](https://yjs.website/tutorial-quill.html) |
|
||||||
| [CodeMirror](https://codemirror.net/) | ✔ | [link](https://yjs.website/tutorial-codemirror.html) |
|
| [CodeMirror](https://codemirror.net/) | ✔ | [y-codemirror](http://github.com/y-js/y-codemirror) | [link](https://yjs.website/tutorial-codemirror.html) |
|
||||||
| [Ace](https://ace.c9.io/) | | [link]() |
|
| [Ace](https://ace.c9.io/) | | [y-ace](http://github.com/y-js/y-ace) | [link]() |
|
||||||
| [Monaco](https://microsoft.github.io/monaco-editor/) | | [link]() |
|
| [Monaco](https://microsoft.github.io/monaco-editor/) | | [y-monaco](http://github.com/y-js/y-monaco) | [link]() |
|
||||||
|
|
||||||
|
### Providers
|
||||||
|
|
||||||
|
Setting up the communication between clients, managing awareness information, and storing shared data for offline usage is quite a hassle. *Providers* manage all that for you and are a good off-the-shelf solution
|
||||||
|
|
||||||
|
* [y-websockets](http://github.com/y-js/y-websockets)
|
||||||
|
* [y-webrtc](http://github.com/y-js/y-webrtc)
|
||||||
|
* [y-dat](http://github.com/y-js/y-dat)
|
||||||
|
|
||||||
### Network providers
|
|
||||||
|
|
||||||
### Shared Types
|
### Shared Types
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ export const transact = (y, f) => {
|
|||||||
if (y._transaction === null) {
|
if (y._transaction === null) {
|
||||||
initialCall = true
|
initialCall = true
|
||||||
y._transaction = new Transaction(y)
|
y._transaction = new Transaction(y)
|
||||||
y.emit('beforeTransaction', [y, y._transaction])
|
y.emit('beforeTransaction', [y._transaction, y])
|
||||||
}
|
}
|
||||||
const transaction = y._transaction
|
const transaction = y._transaction
|
||||||
try {
|
try {
|
||||||
@ -141,7 +141,7 @@ export const transact = (y, f) => {
|
|||||||
} finally {
|
} finally {
|
||||||
if (initialCall) {
|
if (initialCall) {
|
||||||
y._transaction = null
|
y._transaction = null
|
||||||
y.emit('beforeObserverCalls', [y, y._transaction])
|
y.emit('beforeObserverCalls', [transaction, y])
|
||||||
// emit change events on changed types
|
// emit change events on changed types
|
||||||
transaction.changed.forEach((subs, itemtype) => {
|
transaction.changed.forEach((subs, itemtype) => {
|
||||||
itemtype._callObserver(transaction, subs)
|
itemtype._callObserver(transaction, subs)
|
||||||
@ -167,7 +167,7 @@ export const transact = (y, f) => {
|
|||||||
const ds = transaction.deleteSet
|
const ds = transaction.deleteSet
|
||||||
// replace deleted items with ItemDeleted / GC
|
// replace deleted items with ItemDeleted / GC
|
||||||
sortAndMergeDeleteSet(ds)
|
sortAndMergeDeleteSet(ds)
|
||||||
y.emit('afterTransaction', [y, transaction])
|
y.emit('afterTransaction', [transaction, y])
|
||||||
for (const [client, deleteItems] of ds.clients) {
|
for (const [client, deleteItems] of ds.clients) {
|
||||||
/**
|
/**
|
||||||
* @type {Array<AbstractStruct>}
|
* @type {Array<AbstractStruct>}
|
||||||
@ -238,7 +238,7 @@ export const transact = (y, f) => {
|
|||||||
tryToMergeWithLeft(structs, replacedStructPos)
|
tryToMergeWithLeft(structs, replacedStructPos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
y.emit('afterTransactionCleanup', [y, transaction])
|
y.emit('afterTransactionCleanup', [transaction, y])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ export class Y extends Observable {
|
|||||||
*/
|
*/
|
||||||
constructor (conf = {}) {
|
constructor (conf = {}) {
|
||||||
super()
|
super()
|
||||||
|
// todo: change to clientId
|
||||||
this.clientID = random.uint32()
|
this.clientID = random.uint32()
|
||||||
/**
|
/**
|
||||||
* @type {Map<string, AbstractType<YEvent>>}
|
* @type {Map<string, AbstractType<YEvent>>}
|
||||||
@ -151,4 +152,18 @@ export class Y extends Observable {
|
|||||||
this.emit('destroyed', [true])
|
this.emit('destroyed', [true])
|
||||||
super.destroy()
|
super.destroy()
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {function} f
|
||||||
|
*/
|
||||||
|
on (eventName, f) {
|
||||||
|
super.on(eventName, f)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {function} f
|
||||||
|
*/
|
||||||
|
off (eventName, f) {
|
||||||
|
super.off(eventName, f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user