| 1 |
import { operate } from '../util/lift'; |
| 2 |
import { noop } from '../util/noop'; |
| 3 |
import { createOperatorSubscriber } from './OperatorSubscriber'; |
| 4 |
import { innerFrom } from '../observable/innerFrom'; |
| 5 |
export function buffer(closingNotifier) { |
| 6 |
return operate(function (source, subscriber) { |
| 7 |
var currentBuffer = []; |
| 8 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return currentBuffer.push(value); }, function () { |
| 9 |
subscriber.next(currentBuffer); |
| 10 |
subscriber.complete(); |
| 11 |
})); |
| 12 |
innerFrom(closingNotifier).subscribe(createOperatorSubscriber(subscriber, function () { |
| 13 |
var b = currentBuffer; |
| 14 |
currentBuffer = []; |
| 15 |
subscriber.next(b); |
| 16 |
}, noop)); |
| 17 |
return function () { |
| 18 |
currentBuffer = null; |
| 19 |
}; |
| 20 |
}); |
| 21 |
} |
| 22 |
//# sourceMappingURL=buffer.js.map |