---abcde-----f-------gh-----i----> //Events
I have a "work queue" that I want to observe/subscribe to. This is an array of command objects to process. New items of work typically arrive in bursts and they need to be processed serially (in the order received, one at a time, until fully processed).
I'm using RxJS 5.0.0-beta.6. (version imposed by other libraries)
Here is a working example that illustrates the behavior I want, but uses RxJS v4.
The main code in question is this...
var events$ = Rx.Observable.fromEvent(produceEvent, 'click')
.timestamp()
.tap(({timestamp}) => updatePanelAppend(pending, timestamp));
var inProgress$ = events$;
var done$ = inProgress$
.flatMapWithMaxConcurrent(1, ({timestamp}) =>
Rx.Observable.fromPromise(() => {
updatePanelAppend(inProgress, timestamp);
removeFromPanel(pending, timestamp);
return expensiveComputation(getRandomInt(1, 5) * 1000, timestamp)
}));
done$.subscribeOnNext((timestamp) => {
updatePanelAppend(done, timestamp);
removeFromPanel(inProgress, timestamp);
});
http://jsbin.com/meyife/edit?js,output
Given the current beta state of the API and incomplete/changing documentation, I can't figure out how to do this in RxJS 5.
Update: This migration guide for moving from v4 to v5 shows many function that were removed, but does not direct how to do things the new way. Examples of removed operations: .tap, .controlled, .flatMapWithMaxConcurrent (renamed).