baconjs / bacon.js

Functional reactive programming library for TypeScript and JavaScript

Home Page:https://baconjs.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bacon.when loses last event if pattern has a Property without initial value

milankinen opened this issue · comments

This one is working as expected:

const s = Bacon.sequentially(5, [1, 2, 3, 4])
const p = Bacon.sequentially(10, ["lol", "bal"]).toProperty("")
Bacon.when(
  [s, p], (...args) => args
).log("when")
// Outputs:
// when [ 1, '' ]
// when [ 2, 'lol' ]
// when [ 3, 'lol' ]
// when [ 4, 'bal' ]
// when <end>

However, this is not (note that .toProperty() is called without initial value). The number of s events does not matter, the last value is always missing.

const s = Bacon.sequentially(5, [1, 2, 3, 4])
const p = Bacon.sequentially(10, ["lol", "bal"]).toProperty()
Bacon.when(
  [s, p], (...args) => args
).log("when")
// Outputs:
// when [ 1, 'lol' ]
// when [ 2, 'lol' ]
// when [ 3, 'bal' ]
// when <end>

Bacon version is baconjs@2.0.7