當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Subject.next方法代碼示例

本文整理匯總了TypeScript中rxjs/Subject.Subject.next方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Subject.next方法的具體用法?TypeScript Subject.next怎麽用?TypeScript Subject.next使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rxjs/Subject.Subject的用法示例。


在下文中一共展示了Subject.next方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: switch

                message: (message) => {
                    console.debug('Received from server the following : ', message['data']['data']);

                    const communication: ServerCommunication = message['data']['data'];

                    switch(communication['type']){

                        case 'question':
                            this._questions.next(communication);
                            break;

                        case 'notification':
                            console.log('received a notif');
                            this._notifs.next(communication);
                            break;

                        case 'scores':
                            this._scores.next(communication['content']);
                            break;

                        case 'complete':
                            this._questions.complete();
                            break;

                        default:
                            console.log('Type of the communication unknown');
                            break;
                    }
                },
開發者ID:aGautrain,項目名稱:ZetaPush-quizz,代碼行數:29,代碼來源:quizz.service.ts

示例2: inject

      inject([Overlay], (overlay: Overlay) => {
        overlayRef.dispose();
        scrollPosition = 100;

        overlayRef = overlay.create({
          scrollStrategy: overlay.scrollStrategies.close({threshold: 50})
        });

        overlayRef.attach(componentPortal);
        spyOn(overlayRef, 'updatePosition');
        spyOn(overlayRef, 'detach');

        // Scroll down 30px.
        for (let i = 0; i < 30; i++) {
          scrollPosition++;
          scrolledSubject.next();
        }

        // Scroll back up 30px.
        for (let i = 0; i < 30; i++) {
          scrollPosition--;
          scrolledSubject.next();
        }

        expect(overlayRef.updatePosition).toHaveBeenCalledTimes(60);
        expect(overlayRef.detach).not.toHaveBeenCalled();
      }));
開發者ID:ravichandra480,項目名稱:material2,代碼行數:27,代碼來源:close-scroll-strategy.spec.ts

示例3: xit

 xit('Should display notification about cached content only once', () => {
     localStorage.clear();
     activated.next({current: {hash: 'asdf'}} as UpdateActivatedEvent);
     activated.next({current: {hash: 'asdf'}} as UpdateActivatedEvent);
     expect(snackBarServiceStub.displayNotification.called).toBe(true, 'Notification was not displayed');
     expect(snackBarServiceStub.displayNotification.calledOnce).toBe(true, 'Notification was not displayed once');
 });
開發者ID:yantrixs,項目名稱:angular-universal-pwa,代碼行數:7,代碼來源:app.component.spec.ts

示例4: it

      it ('Check collapsed', () => {
        userSettingState = UserSettingUtil.updateUserSettingState(userSettingState, mutable => {
          mutable.swimlane = 'component';
          mutable.defaultCollapsedSwimlane = false;
          mutable.collapsedSwimlanes = Map<string, boolean>({'a': true, 'b': true, 'c': true, 'd': false});
        });
        userSettingSubject.next(userSettingState);
        urlObservable
          .pipe(
            take(1)
          )
          .subscribe(s => {
            expect(s).toContain('hidden-sl=a,b,c');
            expect(s).not.toContain('visible-sl');
        });

        userSettingState = UserSettingUtil.updateUserSettingState(userSettingState, mutable => {
          mutable.swimlane = 'component';
          mutable.defaultCollapsedSwimlane = true;
          mutable.collapsedSwimlanes = Map<string, boolean>({'a': false, 'b': false, 'c': false, 'd': true});
        });
        userSettingSubject.next(userSettingState);
        urlObservable
          .pipe(
            take(1)
          )
          .subscribe(s => {
            expect(s).toContain('visible-sl=a,b,c');
            expect(s).not.toContain('hidden-sl');
        });

      })
開發者ID:rsvoboda,項目名稱:overbaard-redux,代碼行數:32,代碼來源:board-query-params.service.spec.ts

示例5: test

 test("Gives the latest options when options are changed", () => {
     let changingConfig = "omnisharp";
     updateConfig(vscode, changingConfig, 'path', "somePath");
     optionObservable.next(Options.Read(vscode));
     updateConfig(vscode, changingConfig, 'path', "anotherPath");
     optionObservable.next(Options.Read(vscode));
     let options = optionProvider.GetLatestOptions();
     expect(options.path).to.be.equal("anotherPath");
 });
開發者ID:gregg-miskelly,項目名稱:omnisharp-vscode,代碼行數:9,代碼來源:OptionProvider.test.ts

示例6: it

  it('should update the overlay position when the page is scrolled', () => {
    overlayRef.attach(componentPortal);
    spyOn(overlayRef, 'updatePosition');

    scrolledSubject.next();
    expect(overlayRef.updatePosition).toHaveBeenCalledTimes(1);

    scrolledSubject.next();
    expect(overlayRef.updatePosition).toHaveBeenCalledTimes(2);
  });
開發者ID:Chintuz,項目名稱:material2,代碼行數:10,代碼來源:reposition-scroll-strategy.spec.ts

示例7: it

    it('should create a new todo', () => {
        const actions = new Subject<Action>();
        const states = stateFn({ todos: [], visibilityFilter: 'SHOW_ALL' }, actions);

        actions.next(new AddTodoAction(100, 'todo1'));
        actions.next(new AddTodoAction(101, 'todo2'));

        states.subscribe(s => {
            expect(s.todos.length).toEqual(2);
            expect(s.todos[0]).toEqual({ id: 100, text: 'todo1', completed: false });
            expect(s.todos[1]).toEqual({ id: 101, text: 'todo2', completed: false });
        });
    });
開發者ID:gotstago,項目名稱:rxjs-learning,代碼行數:13,代碼來源:actions.spec.ts

示例8: it

    it('should work', () => {
      const subject = new Subject<number>();

      const log: number[] = [];
      subject.map(x => 2 * x + 1)
        .subscribe(next => log.push(next));

      subject.next(2);
      expect(log).toEqual([5]);

      subject.next(3);
      expect(log).toEqual([5, 7]);
    });
開發者ID:loki2302,項目名稱:html5-experiment,代碼行數:13,代碼來源:rxjs.spec.ts


注:本文中的rxjs/Subject.Subject.next方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。