| 284 | * @param {t.TestCase} tc |
| 285 | */ |
| 286 | export 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 |