I have a Bacon.Bus
within an AMD module.
define( 'bus', [ 'bacon' ], function( Bacon ){
return new Bacon.Bus();
} );
Other modules push values onto the bus.
define( 'pusher', [ 'bus' ], function( bus ){
// ...
bus.push( value );
// ...
} );
While other modules listen for values.
define( 'listener', [ 'bus' ], function( bus ){
bus.onValue( function( value ){
// Consume value
} );
} );
Any modules that are currently loaded receive the pushed value; however any modules loaded afterwards do not.
I tried creating a Bacon.Property
to hold the current value.
define( 'bus', [ 'bacon' ], function( Bacon ){
var bus = new Bacon.Bus();
bus.current = bus.toProperty();
return bus;
} );
// The pusher is unchanged
define( 'listener', [ 'bus' ], function( bus ){
bus.current.onValue( function( value ){
// Consume value
} );
} );
This still did not solve the problem though. Whether I attach onValue
to bus
or bus.current
, modules loaded after the fact do not get triggered.
What am I missing?