本文整理汇总了TypeScript中rxjs.Subject.complete方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Subject.complete方法的具体用法?TypeScript Subject.complete怎么用?TypeScript Subject.complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs.Subject
的用法示例。
在下文中一共展示了Subject.complete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('emits 0 initially, the right count when sources emit their own count, and ends with zero', async () => {
const { httpService, http } = setup();
const countA$ = new Rx.Subject<number>();
const countB$ = new Rx.Subject<number>();
const countC$ = new Rx.Subject<number>();
const promise = http
.getLoadingCount$()
.pipe(toArray())
.toPromise();
http.addLoadingCount(countA$);
http.addLoadingCount(countB$);
http.addLoadingCount(countC$);
countA$.next(100);
countB$.next(10);
countC$.next(1);
countA$.complete();
countB$.next(20);
countC$.complete();
countB$.next(0);
httpService.stop();
expect(await promise).toMatchSnapshot();
});
示例2: dispose
/**
* Free up the resources used by the RepresentationChooser.
*/
public dispose() : void {
this._dispose$.next();
this._dispose$.complete();
this._reEstimate$.next();
this._reEstimate$.complete();
this.manualBitrate$.complete();
this.maxAutoBitrate$.complete();
}
示例3: it
it("communicates closure", async () => {
const completionPromise = new Promise<boolean>(resolve => {
messageSubject2.subscribe({ complete: () => resolve(true) });
});
messageSubject1.complete();
expect(await completionPromise).toEqual(true);
});
示例4: _abort
/**
* Free up ressources from this sourceBuffer
*/
_abort() : void {
log.debug("HTSB: Aborting html text track SourceBuffer");
this._remove(0, Infinity);
this._destroy$.next();
this._destroy$.complete();
safelyRemoveChild(this._textTrackElement, this._currentElement);
}
示例5: it
it('should multicast a ConnectableObservable', (done) => {
const expected = [1, 2, 3, 4];
const source = new Subject<number>();
const connectable = source.pipe(multicast(new Subject<number>())) as ConnectableObservable<number>;
const replayed = connectable.pipe(multicast(new ReplaySubject<number>())) as ConnectableObservable<number>;
connectable.connect();
replayed.connect();
source.next(1);
source.next(2);
source.next(3);
source.next(4);
source.complete();
replayed.pipe(
tap({
next(x) {
expect(x).to.equal(expected.shift());
},
complete() {
expect(expected.length).to.equal(0);
}
})
).subscribe(null, done, done);
});
示例6: ngOnDestroy
/**
* On destroy
*/
ngOnDestroy(): void
{
this._destroy();
// Unsubscribe from all subscriptions
this._unsubscribeAll.next();
this._unsubscribeAll.complete();
}
示例7: complete
function complete() {
if (subscription) {
subscription.unsubscribe();
}
subject.next({ kind: JobOutboundMessageKind.End, description });
subject.complete();
inputChannel.complete();
}
示例8: it
it("should translate Observable implementation not from RxJS into RxJS Observables", (done) => {
/* tslint:enable:max-line-length */
const sub1 = new Subject<number>();
const sub2 = new Subject<number>();
const myObs1 = {
subscribe(a : () => void, b : () => void, c : () => {}) {
sub1.subscribe(a, b, c);
return null;
},
};
const myObs2 = {
subscribe(a : () => void, b : () => void, c : () => {}) {
sub2.subscribe(a, b, c);
return null;
},
};
const rxObs1 = castToObservable(myObs1);
const rxObs2 = castToObservable(myObs2);
let itemFromObs1 = 0;
let itemFromObs2 = 0;
rxObs1.subscribe(
(num) => {
switch (itemFromObs1++) {
case 0:
expect(num).toBe(1);
break;
case 1:
expect(num).toBe(12);
break;
case 2:
expect(num).toBe(5);
break;
default:
throw new Error("Invalid item received");
}
},
(err : Error) => {
expect(err.message).toBe("ffob");
expect(itemFromObs1).toBe(3);
rxObs2.subscribe(
() => { itemFromObs2++; },
noop,
() => {
expect(itemFromObs2).toBe(0);
done();
}
);
}
);
sub1.next(1);
sub1.next(12);
sub1.next(5);
sub2.complete();
sub1.error(new Error("ffob"));
});
示例9: test
test('proxy route responds with `503` if `kbnServer` is not ready yet.', async () => {
configService.atPath.mockReturnValue(new BehaviorSubject({ autoListen: true }));
const legacyService = new LegacyService({ env, logger, configService: configService as any });
const kbnServerListen$ = new Subject();
MockKbnServer.prototype.listen = jest.fn(() => {
kbnServerListen$.next();
return kbnServerListen$.toPromise();
});
// Wait until listen is called and proxy route is registered, but don't allow
// listen to complete and make kbnServer available.
await legacyService.setup(setupDeps);
const legacySetupPromise = legacyService.start(startDeps);
await kbnServerListen$.pipe(first()).toPromise();
const mockResponse: any = {
code: jest.fn().mockImplementation(() => mockResponse),
header: jest.fn().mockImplementation(() => mockResponse),
};
const mockResponseToolkit = {
response: jest.fn().mockReturnValue(mockResponse),
abandon: Symbol('abandon'),
};
const mockRequest = { raw: { req: { a: 1 }, res: { b: 2 } } };
const [[{ handler }]] = setupDeps.http.server.route.mock.calls;
const response503 = await handler(mockRequest, mockResponseToolkit);
expect(response503).toBe(mockResponse);
expect({
body: mockResponseToolkit.response.mock.calls,
code: mockResponse.code.mock.calls,
header: mockResponse.header.mock.calls,
}).toMatchSnapshot('503 response');
// Make sure request hasn't been passed to the legacy platform.
const [mockedLegacyPlatformProxy] = MockLegacyPlatformProxy.mock.instances;
expect(mockedLegacyPlatformProxy.emit).not.toHaveBeenCalled();
// Now wait until kibana is ready and try to request once again.
kbnServerListen$.complete();
await legacySetupPromise;
mockResponseToolkit.response.mockClear();
const responseProxy = await handler(mockRequest, mockResponseToolkit);
expect(responseProxy).toBe(mockResponseToolkit.abandon);
expect(mockResponseToolkit.response).not.toHaveBeenCalled();
// Make sure request has been passed to the legacy platform.
expect(mockedLegacyPlatformProxy.emit).toHaveBeenCalledTimes(1);
expect(mockedLegacyPlatformProxy.emit).toHaveBeenCalledWith(
'request',
mockRequest.raw.req,
mockRequest.raw.res
);
});
示例10: Page
(pageJson: any) => {
let page: Page = new Page();
page.id = pageJson.ID;
page.title = pageJson.title;
page.content = pageJson.content; // TODO remove once filtered
retVal.next(page);
console.debug(`Loaded the ${page.title} page`);
retVal.complete();
}