mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
18 lines
368 B
JavaScript
18 lines
368 B
JavaScript
import {StreamBase} from './base';
|
|
|
|
export class MergeStream extends StreamBase {
|
|
|
|
constructor(streams) {
|
|
super();
|
|
this.streams = streams;
|
|
}
|
|
|
|
attach(observer) {
|
|
const detachers = new Array(this.streams.length);
|
|
this.streams.forEach((s, i) => {
|
|
detachers[i] = s.attach(observer);
|
|
});
|
|
return () => detachers.forEach(d => d());
|
|
}
|
|
}
|
|
|