pandastrike / panda-river

Reactive programming in a functional style in JavaScript.
MIT License
1 stars 2 forks source link

combine doesn't handle queued events in the correct order #8

Open dyoder opened 9 years ago

dyoder commented 9 years ago

The test currently passes, but if we queue the events, it fails. This code illustrates the problem:

    click =
      increment: new EventEmitter
      decrement: new EventEmitter

    i = flow [
      events "change", click.increment
      map -> 1
    ]

    j = flow [
      events "change", click.decrement
      map -> -1
    ]

    k = flow [
      combine i, j
      accumulate ((a, b) -> a + b), 0
    ]

    # inc, dec
    click.increment.emit "change"
    assert (yield next k).value == 1
    click.decrement.emit "change"
    assert (yield next k).value == 0
    click.increment.emit "change"
    click.decrement.emit "change"
    click.increment.emit "change"
    assert (yield next k).value == 1
    assert (yield next k).value == 2
    assert (yield next k).value == 1