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


TypeScript NgRedux.subscribe方法代碼示例

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


在下文中一共展示了NgRedux.subscribe方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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(public applicationRef: ApplicationRef) {

        if(process.env.ENV === 'development') {
            if(this.ngRedux) {
                this.ngRedux.replaceReducer(rootMutableReducer);
                this.ngRedux.subscribe(() => applicationRef.tick());
                return;
            }

            this.configureStore();
            this.ngRedux.subscribe(() => applicationRef.tick());
            return;
        }

        this.configureStore();
    }
開發者ID:Polvista,項目名稱:ng2-seed,代碼行數:16,代碼來源:Store.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: constructor

  constructor(
    ngRedux: NgRedux<IAppState>,
    applicationRef: ApplicationRef
  ) {
    this.sampleData$ = ngRedux.select(n => n.sampleReducer.get('sampleData'));

    ngRedux.mapDispatchToTarget((dispatch) => {
      return {
        foo: () => dispatch({
          type: 'App/FOO',
          payload: 'FOO'
        })
      }
    })(this);

    this.unsubscribe = ngRedux.subscribe(() => {
      applicationRef.tick();
    });
  }
開發者ID:rtbm,項目名稱:ng2-webpack-boilerplate,代碼行數:19,代碼來源:my-app.ts

示例5: constructor

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

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

    this.ngRedux = ngRedux;
    this.title$ = app$.map(s => s.get('title'));

    ngRedux.mapDispatchToTarget((dispatch) => {
      return {
        changeRoute: (path) => dispatch(changeRoute(path))
      };
    })(this);

    this.unsubscribe = ngRedux.subscribe(() => {
      applicationRef.tick();
    });

  }
開發者ID:levinmr,項目名稱:angular2-webpack-redux,代碼行數:20,代碼來源:app.component.ts

示例6: constructor

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

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

    this.ngRedux = ngRedux;
    this.users$ = user$.map(s => s.get('users'));
    this.getAllPending$ = user$.map(s => s.get('getAllPending'));
    this.getAllError$ = user$.map(s => s.get('getAllError'));

    ngRedux.mapDispatchToTarget((dispatch) => {
      return {
        getUsers: (id) => dispatch(getUsers(id))
      };
    })(this);

      this.unsubscribe = ngRedux.subscribe(() => {
      applicationRef.tick();
    });
  }
開發者ID:levinmr,項目名稱:angular2-webpack-redux,代碼行數:21,代碼來源:users-page.component.ts

示例7: constructor

 constructor(public ngRedux: NgRedux<IAppStore>){
   ngRedux.subscribe(() => {
     let state = ngRedux.getState();
     console.log(state);
 })
 }
開發者ID:anil0090,項目名稱:angularredux,代碼行數:6,代碼來源:app.component.ts

示例8: subscribe

 subscribe(listener: () => void): Unsubscribe {
     return this.ngRedux.subscribe(listener);
 }
開發者ID:Polvista,項目名稱:ng2-seed,代碼行數:3,代碼來源:Store.ts


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