Merge pull request #629 from synix/fix/outdated-y-instance

remove outdated Y instance in comments
This commit is contained in:
Kevin Jahns 2024-04-13 19:54:23 +02:00 committed by GitHub
commit aee9e14d09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 9 deletions

View File

@ -187,22 +187,22 @@ export class Doc extends ObservableV2 {
/** /**
* Define a shared data type. * Define a shared data type.
* *
* Multiple calls of `y.get(name, TypeConstructor)` yield the same result * Multiple calls of `ydoc.get(name, TypeConstructor)` yield the same result
* and do not overwrite each other. I.e. * and do not overwrite each other. I.e.
* `y.define(name, Y.Array) === y.define(name, Y.Array)` * `ydoc.get(name, Y.Array) === ydoc.get(name, Y.Array)`
* *
* After this method is called, the type is also available on `y.share.get(name)`. * After this method is called, the type is also available on `ydoc.share.get(name)`.
* *
* *Best Practices:* * *Best Practices:*
* Define all types right after the Yjs instance is created and store them in a separate object. * Define all types right after the Y.Doc instance is created and store them in a separate object.
* Also use the typed methods `getText(name)`, `getArray(name)`, .. * Also use the typed methods `getText(name)`, `getArray(name)`, ..
* *
* @template {typeof AbstractType<any>} Type * @template {typeof AbstractType<any>} Type
* @example * @example
* const y = new Y(..) * const ydoc = new Y.Doc(..)
* const appState = { * const appState = {
* document: y.getText('document') * document: ydoc.getText('document')
* comments: y.getArray('comments') * comments: ydoc.getArray('comments')
* } * }
* *
* @param {string} name * @param {string} name

View File

@ -28,7 +28,8 @@ import { callAll } from 'lib0/function'
* possible. Here is an example to illustrate the advantages of bundling: * possible. Here is an example to illustrate the advantages of bundling:
* *
* @example * @example
* const map = y.define('map', YMap) * const ydoc = new Y.Doc()
* const map = ydoc.getMap('map')
* // Log content when change is triggered * // Log content when change is triggered
* map.observe(() => { * map.observe(() => {
* console.log('change triggered') * console.log('change triggered')
@ -37,7 +38,7 @@ import { callAll } from 'lib0/function'
* map.set('a', 0) // => "change triggered" * map.set('a', 0) // => "change triggered"
* map.set('b', 0) // => "change triggered" * map.set('b', 0) // => "change triggered"
* // When put in a transaction, it will trigger the log after the transaction: * // When put in a transaction, it will trigger the log after the transaction:
* y.transact(() => { * ydoc.transact(() => {
* map.set('a', 1) * map.set('a', 1)
* map.set('b', 1) * map.set('b', 1)
* }) // => "change triggered" * }) // => "change triggered"