Skip to content

flatMapConcat does not buffer #589

Closed
@kraf

Description

@kraf

flatMapConcat does not seem to buffer the events of the other stream(s). Am I understanding the docs wrong here?

var s1 = Bacon.sequentially(100, [1,2,3]);
var s2 = Bacon.sequentially(100, [4,5,6,7,8,9,10]);
var s = Bacon.fromArray([s1, s2]).flatMapConcat(function(stream) { return stream; });

s2.onValue(function(x) {
    console.log('x', x);
});

s.onValue(function(d) {
    console.log(d);
});
s.onEnd(function() {
    console.log('<END>');
});

This outputs

x 4
1
x 5
2
x 6
3
x 7
7
x 8
8
x 9
9
x 10
10
<END>

I would like something like

...
x 6
3
4
5
6
x 7
7
x 8
8
...

Background: I am trying to read from a database up to the current point in time and seamlessly switch over to a live stream of data getting pushed into the store. I can do the buffering manually but was wondering if this can be accomplished using the primitives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions