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


TypeScript ObservableWrapper.subscribe方法代码示例

本文整理汇总了TypeScript中angular2/src/facade/async.ObservableWrapper.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ObservableWrapper.subscribe方法的具体用法?TypeScript ObservableWrapper.subscribe怎么用?TypeScript ObservableWrapper.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/facade/async.ObservableWrapper的用法示例。


在下文中一共展示了ObservableWrapper.subscribe方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: start

  start(): void {
    this._bus.initChannel(SETUP_CHANNEL, false);
    var sink = this._bus.to(SETUP_CHANNEL);
    var source = this._bus.from(SETUP_CHANNEL);

    ObservableWrapper.subscribe(source, (message: string) => {
      if (StringWrapper.equals(message, "ready")) {
        ObservableWrapper.callNext(sink, {"rootUrl": this.rootUrl});
      }
    });
  }
开发者ID:MingXingTeam,项目名称:awesome-front-end,代码行数:11,代码来源:setup.ts

示例2: it

 it('delivers events asynchronously', inject([AsyncTestCompleter], (async) => {
      var e = new EventEmitter();
      var log = [];
      ObservableWrapper.subscribe(e, (x) => {
        log.push(x);
        expect(log).toEqual([1, 3, 2]);
        async.done();
      });
      log.push(1);
      ObservableWrapper.callEmit(e, 2);
      log.push(3);
    }));
开发者ID:kreo,项目名称:angular-2-bootstraping,代码行数:12,代码来源:async_spec.ts

示例3: inject

       inject([AsyncTestCompleter, NgZone], (async, zone: MockNgZone) => {
         setup(false, zone);

         var wasCalled = false;
         ObservableWrapper.subscribe(bus.from(CHANNEL), (message) => { wasCalled = true; });
         ObservableWrapper.callEmit(bus.to(CHANNEL), "hi");

         flushMessages(() => {
           expect(wasCalled).toBeTruthy();
           async.done();
         });
       }), 10000);
开发者ID:1186792881,项目名称:angular,代码行数:12,代码来源:message_bus_spec.ts

示例4: expect

 .then((_) => {
   ObservableWrapper.subscribe<string>(eventBus, (ev) => {
     if (ev.startsWith('routerCanActivate')) {
       completer.resolve(false);
     }
   });
   rtr.navigateByUrl('/can-activate/a').then((_) => {
     fixture.detectChanges();
     expect(fixture.debugElement.nativeElement).toHaveText('');
     expect(log).toEqual(['routerCanActivate: null -> /can-activate']);
     async.done();
   });
 });
开发者ID:LordBinary,项目名称:angular,代码行数:13,代码来源:lifecycle_hook_spec.ts

示例5: it

      it('should return the correct status code', inject([AsyncTestCompleter], async => {
           var statusCode = 418;
           var connection = new XHRConnection(sampleRequest, new MockBrowserXHR(),
                                              new ResponseOptions({status: statusCode}));

           ObservableWrapper.subscribe<Response>(connection.response, res => {
             expect(res.status).toBe(statusCode);
             async.done();
           });

           existingXHRs[0].setStatusCode(statusCode);
           existingXHRs[0].dispatchEvent('load');
         }));
开发者ID:lavinjj,项目名称:angular,代码行数:13,代码来源:xhr_backend_spec.ts

示例6: inject

       inject([AsyncTestCompleter], (async) => {
         const CHANNEL = "CHANNEL 1";
         const MESSAGE = "Test message";
         bus.initChannel(CHANNEL, false);

         var fromEmitter = bus.from(CHANNEL);
         ObservableWrapper.subscribe(fromEmitter, (message: any) => {
           expect(message).toEqual(MESSAGE);
           async.done();
         });
         var toEmitter = bus.to(CHANNEL);
         ObservableWrapper.callEmit(toEmitter, MESSAGE);
       }));
开发者ID:844496869,项目名称:angular,代码行数:13,代码来源:message_bus_spec.ts

示例7: it

 it("should return promises to the worker", inject([Serializer], (serializer) => {
      var broker = new ServiceMessageBroker_(messageBuses.ui, serializer, CHANNEL);
      broker.registerMethod(TEST_METHOD, [PRIMITIVE], (arg1) => {
        expect(arg1).toEqual(PASSED_ARG_1);
        return PromiseWrapper.wrap(() => { return RESULT; });
      });
      ObservableWrapper.callEmit(messageBuses.worker.to(CHANNEL),
                                 {'method': TEST_METHOD, 'id': ID, 'args': [PASSED_ARG_1]});
      ObservableWrapper.subscribe(messageBuses.worker.from(CHANNEL), (data: any) => {
        expect(data.type).toEqual("result");
        expect(data.id).toEqual(ID);
        expect(data.value).toEqual(RESULT);
      });
    }));
开发者ID:1186792881,项目名称:angular,代码行数:14,代码来源:service_message_broker_spec.ts

示例8: it

 it("should fire an event after the value has been updated", inject([AsyncTestCompleter], (async) => {
   ObservableWrapper.subscribe(g.valueChanges, (value) => {
     expect(g.value).toEqual({
       'one': 'new1',
       'two': 'old2'
     });
     expect(value).toEqual({
       'one': 'new1',
       'two': 'old2'
     });
     async.done();
   });
   c1.updateValue("new1");
 }));
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:14,代码来源:model_spec.ts

示例9: inject

       inject([AsyncTestCompleter], (async) => {
         runNgZoneNoLog(() => macroTask(_log.fn('run')));

         ObservableWrapper.subscribe(_zone.onStable, (_) => {
           NgZone.assertNotInAngularZone();
           _log.add('onMyTaskDone');
         });

         macroTask(() => {
           expect(_log.result())
               .toEqual('onUnstable; run; onMicrotaskEmpty; onStable; onMyTaskDone');
           async.done();
         });
       }), testTimeout);
开发者ID:844496869,项目名称:angular,代码行数:14,代码来源:ng_zone_spec.ts

示例10: it

 it('deletes micropost when confirmed', done => {
   const cmp:Feed = cmpDebugElement.componentInstance;
   const testCmp:TestCmp = ctx.fixture.debugElement.componentInstance;
   const deleteLink = DOM.querySelector(cmpDebugElement.nativeElement, '.delete');
   spyOn(window, 'confirm').and.returnValue(true);
   spyOn(cmp, 'list');
   spyOn(testCmp, 'listenDeleted');
   ObservableWrapper.subscribe(cmp.deleted, () => {
     expect(cmp.list).toHaveBeenCalled();
     expect(testCmp.listenDeleted).toHaveBeenCalled();
     done();
   });
   deleteLink.click();
 });
开发者ID:windwang,项目名称:angular2-app,代码行数:14,代码来源:Feed.spec.ts


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