@tdb/util
Version:
Shared helpers and utilities.
36 lines (30 loc) • 729 B
text/typescript
import { expect } from 'chai';
import { Subject } from 'rxjs';
import { share, takeUntil } from 'rxjs/operators';
describe('libs.rxjs', () => {
it('piping', () => {
class Foo {
private _disposed$ = new Subject();
private _events$ = new Subject();
public events$ = this._events$.pipe(
takeUntil(this._disposed$),
share(),
);
public next() {
this._events$.next();
}
public dispose() {
this._disposed$.next();
}
}
let count = 0;
const foo = new Foo();
foo.events$.subscribe(() => count++);
foo.next();
foo.next();
expect(count).to.eql(2);
foo.dispose();
foo.next();
expect(count).to.eql(2);
});
});