Skip to content

Doing multiple changes inside transaction() results multiple invocations of observer subscribed via subscribe(). #184

Open
@j-sen

Description

Doing multiple changes inside transaction() results multiple invocations of observer subscribed via subscribe().

How to reproduce:

import 'https://unpkg.com/sinuous@0.27.12/dist/observable.js'
const {observable, subscribe, transaction, root}= self.observable
root(() => {
  const a = observable(1)
  const b = observable(2)
  const log = []
  subscribe(() => {
    log.push(a() + b())
  })
  transaction(() => {
    a(10)
    b(20)
  })
  // Expected  3;30
  // Got       3;12;30
  console.assert(log.join(';') === '3;30')
})

Link to https://CodePen.io/j-sen/pen/OJjNKVK

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions