• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript BehaviorSubject.BehaviorSubject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: function

export default function(options: CanvasOptions) {
  const write  = new Subject<DragDeltaLog>();
  const clear  = new Subject<any>();
  const scale  = new BehaviorSubject<any>(true);
  const toggle = new Subject<any>();

  const canvas  = options.canvasElement as HTMLCanvasElement;
  const context = canvas.getContext("2d");
  if (context === null) {
    throw new TypeError('unreachable: canvas should be not `null`');
  }

  write.subscribe(writeCanvasTo(context, options.color));
  clear.subscribe(clearCanvasTo(context));

  scale
    .map(() => window.innerWidth)
    .subscribe(attributeAssignOf(canvas, 'width'));
  scale
    .map(() => window.innerHeight)
    .subscribe(attributeAssignOf(canvas, 'height'));

  toggle
    .scan((acc) => !acc, false)
    .map((bool) => bool ? 'false' : 'true')
    .subscribe(attributeAssignOf(canvas, 'aria-hidden'));

  return {
    cvWrite  : write,
    cvClear  : clear,
    cvToggle : toggle,
    cvScale  : scale
  };

}
开发者ID:1000ch,项目名称:Talkie,代码行数:35,代码来源:canvas.ts


示例2: beforeEach

    beforeEach(() => {
        addProviders([
            { provide: Platform, useClass: MockClass },
            { provide: Http, useClass: HttpMock },
            { provide: NavController, useClass: NavMock },
            { provide: DataService, useClass: MockDataService },
        ]);
 
        platform      = new MockClass();
        navMock       = new NavMock();
        window.localStorage.setItem('project_data', JSON.stringify(platform.getData()));

        data          = platform.getData();
        var _data     = JSON.stringify(data);

        //Set Initial State
        window.localStorage.setItem('project_data', _data);
        window.localStorage.setItem('project_id', '5');

        observable    = new BehaviorSubject(data);
        observable.next(data);

        dataService   = new DataService(httpMock);
        spyOn(dataService, 'fetchData').and.returnValue(observable);

        chart         = new Chart(dataService);
        netattraction = new Netattraction();
    });
开发者ID:peb7268,项目名称:ionic-dashboard,代码行数:28,代码来源:netattraction.spec.ts


示例3: getWorkItemList

    getWorkItemList(idList: Array<number>) : Observable<WorkItemList> {
        let returnValue = new WorkItemList();
        let subject = new BehaviorSubject<WorkItemList>(null);

        if (idList.length > 0) {
            let server = this.window.localStorage.getItem('server');
            
            let workItemUrl = server + '/DefaultCollection/_apis/wit/WorkItems?ids=' + idList.join() + '&fields=System.Id,System.WorkItemType,System.Title,System.AssignedTo,System.State&api-version=1.0';

            this.oAuthHttp.get(workItemUrl).subscribe(res => {
                let result = res.json();

                result.value.forEach(workItemJson => {
                    let workItem = new WorkItem();
                    workItem.populate(workItemJson);
                    returnValue.push(workItem);
                });

                subject.next(returnValue);
            });
        }
        else {
            subject.next(returnValue);
        }

        return subject.asObservable();
    }
开发者ID:CaringIsCreepy,项目名称:VSTS-Mobile,代码行数:27,代码来源:work-item-service.ts


示例4: it

 it('should handle dynamic queries that return empty sets', async (done) => {
   const ITEMS = 10;
   let count = 0;
   let firstIndex = 0;
   let pricefilter$ = new BehaviorSubject<number|null>(null);
   const randomCollectionName = randomName(afs.firestore);
   const ref = afs.firestore.collection(`${randomCollectionName}`);
   let names = await createRandomStocks(afs.firestore, ref, ITEMS);
   const sub = pricefilter$.switchMap(price => {
     return afs.collection(randomCollectionName, ref => price ? ref.where('price', '==', price) : ref).valueChanges()
   }).subscribe(data => {
     count = count + 1;
     // the first time should all be 'added'
     if(count === 1) {
       expect(data.length).toEqual(ITEMS);
       pricefilter$.next(-1);
     }
     // on the second round, we should have filtered out everything
     if(count === 2) {
       expect(data.length).toEqual(0);
       sub.unsubscribe();
       deleteThemAll(names, ref).then(done).catch(done.fail);
     }
   });
 });
开发者ID:acipher,项目名称:angularfire2,代码行数:25,代码来源:collection.spec.ts


示例5: beforeEach

      beforeEach(async(() => {
        dispatcher = new ListStateDispatcher();
        state = new ListState(dispatcher);

        /* tslint:disable */
        let itemsArray = [
          { id: '1', column1: '30', column2: 'Apple',
            column3: 1, column4: moment().add(1, 'minute') },
          { id: '2', column1: '01', column2: 'Banana',
            column3: 3, column4: moment().add(6, 'minute') },
          { id: '3', column1: '11', column2: 'Banana',
            column3: 11, column4: moment().add(4, 'minute') },
          { id: '4', column1: '12', column2: 'Carrot',
            column3: 12, column4: moment().add(2, 'minute') },
          { id: '5', column1: '12', column2: 'Edamame',
            column3: 12, column4: moment().add(5, 'minute') },
          { id: '6', column1: null, column2: null,
            column3: 20, column4: moment().add(3, 'minute') },
          { id: '7', column1: '22', column2: 'Grape',
            column3: 21, column4: moment().add(7, 'minute') }
        ];

        bs = new BehaviorSubject<Array<any>>(itemsArray);
        items = bs.asObservable();

        TestBed.configureTestingModule({
          imports: [
            ListFixturesModule,
            SkyListModule,
            SkyListViewGridModule,
            SkyListToolbarModule,
            FormsModule
          ],
          providers: [
            { provide: 'items', useValue: items }
          ]
        })
        .overrideComponent(SkyListComponent, {
          set: {
            providers: [
              { provide: ListState, useValue: state },
              { provide: ListStateDispatcher, useValue: dispatcher }
            ]
          }
        });

        fixture = TestBed.createComponent(ListSelectedTestComponent);
        nativeElement = fixture.nativeElement as HTMLElement;
        element = fixture.debugElement as DebugElement;
        component = fixture.componentInstance;

        fixture.detectChanges();

        // always skip the first update to ListState, when state is ready
        // run detectChanges once more then begin tests
        state.skip(1).take(1).subscribe(() => fixture.detectChanges());
        fixture.detectChanges();

      }));
开发者ID:Blackbaud-DanHamlin,项目名称:skyux2,代码行数:59,代码来源:list.component.spec.ts


示例6: getSpinner

 getSpinner(name: string): any {
     if (this.spinners.has(name)) {
         return this.spinners.get(name);
     }
     let subject = new BehaviorSubject(false);
     this.sources.set(name, subject);
     this.spinners.set(name, subject.asObservable());
     return this.spinners.get(name);
 }
开发者ID:finleysg,项目名称:bhmc,代码行数:9,代码来源:spinner.service.ts


示例7: getSpinnerSource

 private getSpinnerSource(name: string): BehaviorSubject<boolean> {
     if (this.sources.has(name)) {
         return this.sources.get(name);
     }
     let subject = new BehaviorSubject(false);
     this.sources.set(name, subject);
     this.spinners.set(name, subject.asObservable());
     return this.sources.get(name);
 }
开发者ID:finleysg,项目名称:bhmc,代码行数:9,代码来源:spinner.service.ts


示例8: it

  it('#calculateStandings should do nothing if there aren\'t any players', () => {
    const playersSubject = new BehaviorSubject<Player[]>([]);
    const fakePlayerService = {
      players: playersSubject.asObservable()
    };
    const submittedPairingsSubject = new BehaviorSubject<Pairing[]>([]);
    const fakePairingService = {
      submittedPairings: submittedPairingsSubject.asObservable()
    };

    service = new StandingsService(fakePairingService as PairingService, fakePlayerService as PlayerService);
  });
开发者ID:sten626,项目名称:mirror-match,代码行数:12,代码来源:standings.service.spec.ts


示例9:

 this.textInput.valueChanges.debounceTime(500).subscribe((value)=>{
     if(this._validate(value)) {
         this.textInput.setValue(value);
         this.value.next(value);
     } else {
         this.textInput.setValue(this._currentValue);
         this.value.next(this._currentValue);
     }
 })
开发者ID:EremenkoAndrey,项目名称:july,代码行数:9,代码来源:product-count.component.ts


示例10: destroy

 destroy() {
   this._date.unsubscribe()
   this._first.unsubscribe()
   
   this._helloMessageSubject.unsubscribe()
   this._helloMessageConnect.unsubscribe()
   
   this._paramsSubject.unsubscribe()
   
   this._last.unsubscribe()
 }
开发者ID:iamssen,项目名称:angular2-rx-sample,代码行数:11,代码来源:rx.model.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript index.BehaviorSubject类代码示例发布时间:2022-05-25
下一篇:
TypeScript AsyncSubject.AsyncSubject类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap