当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Subject.complete方法代码示例

本文整理汇总了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();
  });
开发者ID:elastic,项目名称:kibana,代码行数:26,代码来源:http_service.test.ts

示例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();
 }
开发者ID:canalplus,项目名称:rx-player,代码行数:11,代码来源:representation_chooser.ts

示例3: it

 it("communicates closure", async () => {
   const completionPromise = new Promise<boolean>(resolve => {
     messageSubject2.subscribe({ complete: () => resolve(true) });
   });
   messageSubject1.complete();
   expect(await completionPromise).toEqual(true);
 });
开发者ID:nteract,项目名称:nteract,代码行数:7,代码来源:message-subject-spec.ts

示例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);
 }
开发者ID:canalplus,项目名称:rx-player,代码行数:10,代码来源:html_text_source_buffer.ts

示例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);
  });
开发者ID:DallanQ,项目名称:rxjs,代码行数:27,代码来源:multicast-spec.ts

示例6: ngOnDestroy

    /**
     * On destroy
     */
    ngOnDestroy(): void
    {
        this._destroy();

        // Unsubscribe from all subscriptions
        this._unsubscribeAll.next();
        this._unsubscribeAll.complete();
    }
开发者ID:karthik12ui,项目名称:fuse-angular-full,代码行数:11,代码来源:fuse-perfect-scrollbar.directive.ts

示例7: complete

 function complete() {
   if (subscription) {
     subscription.unsubscribe();
   }
   subject.next({ kind: JobOutboundMessageKind.End, description });
   subject.complete();
   inputChannel.complete();
 }
开发者ID:angular,项目名称:angular-cli,代码行数:8,代码来源:create-job-handler.ts

示例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"));
  });
开发者ID:canalplus,项目名称:rx-player,代码行数:58,代码来源:cast_to_observable.test.ts

示例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
    );
  });
开发者ID:elastic,项目名称:kibana,代码行数:57,代码来源:legacy_service.test.ts

示例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();
			}
开发者ID:dsebastien,项目名称:midnightLightV2,代码行数:9,代码来源:pages.service.ts


注:本文中的rxjs.Subject.complete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。