當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。