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

TypeScript ng2-redux.NgRedux类代码示例

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

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



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

示例1: constructor

  constructor(
    private ngRedux: NgRedux<IAppState>,
    applicationRef: ApplicationRef,
    private sessionActions: SessionActions) {

    const session$: Observable<Map<string, any>>
      = ngRedux.select<Map<string, any>>('session');

    this.hasError$ = session$.map(s => !!s.get('hasError'));
    this.isLoading$ = session$.map(s => !!s.get('isLoading'));
    this.loggedIn$ = session$.map(s => !!s.get('token'));
    this.loggedOut$ = this.loggedIn$.map(loggedIn => !loggedIn);

    this.userName$ = session$.map(s => {
        return [
          s.getIn(['user', 'firstName'], ''),
          s.getIn(['user', 'lastName'], '')
         ].join(' ');
      });

    ngRedux.mapDispatchToTarget((dispatch) => {
      return {
        login: (credentials) => dispatch(
          this.sessionActions.loginUser(credentials)),
        logout: () => dispatch(
          this.sessionActions.logoutUser())
      };
    })(this);

    this.unsubscribe = ngRedux.subscribe(() => {
      applicationRef.tick();
    });
  }
开发者ID:lokeshjain2008,项目名称:angular2-redux-starter,代码行数:33,代码来源:sample-app.ts


示例2: constructor

 constructor(
     ngRedux: NgRedux<IAppState>,
     bankService: BankService // instantiating service because its not by bootstrap()!
 ) {
     this.pot$ = ngRedux.select(n => n.bank.get('pot'));
     this.bank$ = ngRedux.select(n => n.bank.get('bank'));
 }
开发者ID:asiam9,项目名称:angularattack2016-dices-game,代码行数:7,代码来源:bank.ts


示例3: constructor

  constructor(
    ngRedux: NgRedux<AppState>,
    applicationRef: ApplicationRef) {

    this.ngRedux = ngRedux;

    ngRedux.mapDispatchToTarget((dispatch) => {
      return {
        setTitle: (title) => dispatch(setTitle(title))
      };
    })(this);

    this.unsubscribe = ngRedux.subscribe(() => {
      applicationRef.tick();
    });
  }
开发者ID:levinmr,项目名称:angular2-webpack-redux,代码行数:16,代码来源:home-page.component.ts


示例4: ngOnInit

 ngOnInit() {
   this.counter$ = this.ngRedux
     .select(n => n.counter.get('count'));
     
   this.ngRedux.mapDispatchToTarget(CounterActions)(this);
   
 }
开发者ID:e-schultz,项目名称:angular2-redux-example,代码行数:7,代码来源:counter-page.ts


示例5: ngOnInit

    ngOnInit() {
        this.needMapSubscription = this.ngRedux
            .select<any>(state => state.needMap)
            .subscribe(needMap => {
                // console.log('PeoplePanel.needMap', needMap);
                this.needMap = needMap;
            });

        this.personMapSubscription = this.ngRedux
            .select<any>(state => state.personMap)
            .subscribe(personMap => {
                // console.log('PeoplePanel.personMap', personMap);
                this.personMap = personMap;
            });

        this.matchedPeopleSubscription = this.ngRedux
            .select<number[]>(state => state.matchedPeople)
            .subscribe(matchedPeople => {
                // console.log('PeoplePanel.matchedPeople', matchedPeople);
                this.matchedPeople = matchedPeople;
            });

        this.selectedNeedSubscription = this.ngRedux
            .select<number>(state => state.selectedNeedId)
            .subscribe(selectedNeedId => {
                // console.log('PeoplePanel.selectedNeedId', selectedNeedId);
                this.selectedNeedId = selectedNeedId;
                this.handleNeedSelected(selectedNeedId);
            });
    }
开发者ID:jbhg,项目名称:staffer,代码行数:30,代码来源:people-panel.component.ts


示例6: updateQueryParams

 updateQueryParams() {
   this.router.navigate(['search'], {
     queryParams: {
       term: this.ngRedux.getState().search.get('term'),
       page: this.ngRedux.getState().search.get('page'),
     }
   });
 }
开发者ID:andrewlo,项目名称:angular2-redux-giphy,代码行数:8,代码来源:search.page.ts


示例7: extractUser

    extractUser(res: Response): IUser{
        let user = res.json().data;
        let state = this.store.getState();
        let url = state.lastVisitedUrl;

        this.store.dispatch(updateUser(user));
        this.router.navigate([url]);

        return user;
    }
开发者ID:jsruvi,项目名称:deberc_react,代码行数:10,代码来源:auth.service.ts


示例8: ngOnInit

  ngOnInit(): void {

    this.ngRedux
      .select(state => state.core.message)
      .subscribe(message => this.message = message);

    this.ngRedux
      .select(state => state.core.errors)
      .subscribe(errors => this.errors = errors);
  }
开发者ID:echo-anna,项目名称:SoftUni,代码行数:10,代码来源:message.handler.component.ts


示例9: ngOnInit

 ngOnInit() {
   
   this.selector = this.ngRedux
     .select(state => state.session, is)
     .subscribe(n => { 
       this.session = n;
       this.isLoggedIn = n.get('token', false);
     });
 
   this.ngRedux.mapDispatchToTarget(this.mapDispatchToThis)(this);
   
 }
开发者ID:e-schultz,项目名称:angular2-redux-example,代码行数:12,代码来源:sample-app.ts


示例10: moment

  activityConnector() {
    this.activities$ = this.ngRedux.select(['eventData', 'items'])
    .map((activity:Map<string, any>) => {
      var b = activity.filter((activity:Map<string, any>) => {
        return this.shouldInclude(activity);
      })
      .toList()
      .toJS()
      console.log(b);
      return activity.filter((activity:Map<string, any>) => {
        return this.shouldInclude(activity);
      })
      .toList()
      .toJS()
      .sort((a, b) => {
        return moment(a.startDate.iso) > moment(b.startDate.iso);
      })
    })

    this.activitiesSub$ = this.activities$.subscribe((x) => {
      this.zone.run(() => {
        console.log('Search Update');
      })
    });

  }
开发者ID:hack4change,项目名称:hambasafe-client,代码行数:26,代码来源:activity-list.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript ng2-redux-router.NgReduxRouter类代码示例发布时间:2022-05-25
下一篇:
TypeScript ng2-redux.DevToolsExtension类代码示例发布时间: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