Skip to content

bus.end() call lost when called synchronously after takeUntil on bus.mapEnd(null) #517

Closed
@Macil

Description

@Macil

This code should print "got value 1" and stop, but instead "got value 1" and "got value 2" are outputted. However, if you add a subscriber to the bus first by adding bus.log(); after defining the bus, it works as expected.

var Bacon = require('baconjs');
var bus = new Bacon.Bus();
var s = Bacon.once(1).merge(Bacon.later(10, 2));
s.takeUntil(bus.mapEnd(null)).onValue(function(value) {
  console.log('got value', value);
  bus.end();
});

Calling bus.end() before there are any subscribers usually does nothing (I'm a little uncomfortable with this, but it's not what this issue is specifically). However, the .takeUntil(bus.mapEnd(null)) does add a subscriber to the bus, so I'd expect the later bus.end() call to work.

Bacon 0.7.41 from NPM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions