MCPcopy
hub / github.com/yjs/yjs / testNestedObserverEvents

Function testNestedObserverEvents

tests/y-array.tests.js:286–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284 * @param {t.TestCase} tc
285 */
286export const testNestedObserverEvents = tc => {
287 const { array0, users } = init(tc, { users: 2 })
288 /**
289 * @type {Array<number>}
290 */
291 const vals = []
292 array0.observe(() => {
293 if (array0.length === 1) {
294 // inserting, will call this observer again
295 // we expect that this observer is called after this event handler finishedn
296 array0.insert(1, [1])
297 vals.push(0)
298 } else {
299 // this should be called the second time an element is inserted (above case)
300 vals.push(1)
301 }
302 })
303 array0.insert(0, [0])
304 t.compareArrays(vals, [0, 1])
305 t.compareArrays(array0.toArray(), [0, 1])
306 compare(users)
307}
308
309/**
310 * @param {t.TestCase} tc

Callers

nothing calls this directly

Calls 6

initFunction · 0.90
compareFunction · 0.90
observeMethod · 0.80
insertMethod · 0.80
pushMethod · 0.80
toArrayMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…