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


TypeScript async.ObservableWrapper类代码示例

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


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

示例1: transform

  transform(docObs: any, args: List<any> = null): any {
    if (!this._subscription) {
      var self = this;
      this._subscription = ObservableWrapper.subscribe(docObs, value => {
        self._updateLatestValue(value);
      });
      return null;
    }

    if (!this._isUpdated) {
      return this._latestReturnedValue;
    }

    this._isUpdated = false;
    this._latestReturnedValue = this._latestValue;
    return WrappedValue.wrap(this._latestValue);
  }
开发者ID:jdelgadoalfonso,项目名称:ng2-pipes,代码行数:17,代码来源:md_pipe.ts

示例2: expect

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

示例3: it

		it('should append an svg as child of self', inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
			let html = '<div class="logo" logo></div>';
			ObservableWrapper.subscribe(backend.connections, (connection: MockConnection) => {
				// console.log(connection);
				connection.mockRespond(response)
			});
			tcb
				.overrideTemplate(Test, html)
				.createAsync(Test)
				.then((rootTC) => {
					rootTC.detectChanges();
					let logo: Element = DOM.querySelector(rootTC.nativeElement, '.logo');
					let prefixSelector = isNativeShadowDOMSupported ? '* /deep/ ' : ''; // soon use '>>>' https://www.chromestatus.com/features/6750456638341120
					// console.log(logo.firstChild, prefixSelector);
					// expect(logo.querySelector(prefixSelector + 'svg')).not.toBe(null);
					async.done();
				});
		}));
开发者ID:Luphia,项目名称:Laria,代码行数:18,代码来源:logo.spec.ts

示例4: expect

             .then((_) => {
               fixture.detectChanges();
               expect(fixture.debugElement.nativeElement).toHaveText('routerCanDeactivate {A}');
               expect(log).toEqual([]);

               ObservableWrapper.subscribe<string>(eventBus, (ev) => {
                 if (ev.startsWith('routerCanDeactivate')) {
                   completer.resolve(false);
                 }
               });

               rtr.navigateByUrl('/a').then((_) => {
                 fixture.detectChanges();
                 expect(fixture.debugElement.nativeElement).toHaveText('routerCanDeactivate {A}');
                 expect(log).toEqual(['routerCanDeactivate: /can-deactivate -> /a']);
                 async.done();
               });
             });
开发者ID:ProjectFrank,项目名称:angular,代码行数:18,代码来源:lifecycle_hook_spec.ts

示例5: it

 it("should fire an event every time a control is updated", inject([AsyncTestCompleter], (async) => {
   var loggedValues = [];
   ObservableWrapper.subscribe(g.valueChanges, (value) => {
     ListWrapper.push(loggedValues, value);
     if (loggedValues.length == 2) {
       expect(loggedValues).toEqual([{
         "one": "new1",
         "two": "old2"
       }, {
         "one": "new1",
         "two": "new2"
       }]);
       async.done();
     }
   });
   c1.updateValue("new1");
   c2.updateValue("new2");
 }));
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:18,代码来源:model_spec.ts

示例6: inject

       inject([AsyncTestCompleter], (async) => {
         // the only practical use-case to run a callback inside the zone is
         // change detection after "onTurnDone". That's the only case tested.
         var turnDone = false;
         ObservableWrapper.subscribe(_zone.onTurnDone, (_) => {
           _log.add('onTurnDone');
           if (turnDone) return;
           _zone.run(() => { microTask(() => {}); });
           turnDone = true;
         });

         macroTask(() => { _zone.run(_log.fn('run')); });

         macroTask(() => {
           expect(_log.result()).toEqual('run; onTurnDone; onTurnDone');
           async.done();
         }, resultTimer);
       }), testTimeout);
开发者ID:Ashok-Pal,项目名称:angular,代码行数:18,代码来源:ng_zone_spec.ts

示例7: inject

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

         // the only practical use-case to run a callback inside the zone is
         // change detection after "onMicrotaskEmpty". That's the only case tested.
         var turnDone = false;
         ObservableWrapper.subscribe(_zone.onMicrotaskEmpty, (_) => {
           _log.add('onMyMicrotaskEmpty');
           if (turnDone) return;
           _zone.run(() => { scheduleMicroTask(() => {}); });
           turnDone = true;
         });

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

示例8: it

      it('should ignore load/callback when disposed', inject([AsyncTestCompleter], async => {
           var connection = new JSONPConnection(sampleRequest, new MockBrowserJsonp());
           let spy = new SpyObject();
           let loadSpy = spy.spy('load');
           let errorSpy = spy.spy('error');
           let returnSpy = spy.spy('cancelled');

           ObservableWrapper.subscribe(connection.response, loadSpy, errorSpy, returnSpy);
           connection.dispose();
           expect(connection.readyState).toBe(ReadyStates.CANCELLED);

           connection.finished('Fake data');
           existingScripts[0].dispatchEvent('load');

           TimerWrapper.setTimeout(() => {
             expect(loadSpy).not.toHaveBeenCalled();
             expect(errorSpy).not.toHaveBeenCalled();
             expect(returnSpy).toHaveBeenCalled();
             async.done();
           }, 10);
         }));
开发者ID:goderbauer,项目名称:angular,代码行数:21,代码来源:jsonp_backend_spec.ts

示例9: it

    it('should call onEventDone once at the end of event', inject([AsyncTestCompleter], (async) => {
         // The test is set up in a way that causes the zone loop to run onTurnDone twice
         // then verified that onEventDone is only called once at the end
         logOnEventDone();

         var times = 0;
         ObservableWrapper.subscribe(_zone.onTurnDone, (_) => {
           times++;
           _log.add(`onTurnDone ${times}`);
           if (times < 2) {
             // Scheduling a microtask causes a second digest
             _zone.run(() => { microTask(() => {}); });
           }
         });

         macroTask(() => { _zone.run(_log.fn('run')); });

         macroTask(() => {
           expect(_log.result()).toEqual('run; onTurnDone 1; onTurnDone 2; onEventDone');
           async.done();
         }, resultTimer);
       }), testTimeout);
开发者ID:Ashok-Pal,项目名称:angular,代码行数:22,代码来源:ng_zone_spec.ts


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