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


TypeScript Store.subscribe方法代码示例

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


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

示例1: getTodos

 private getTodos(key: string): Todo[] {
   let todos = [];
   this.store.subscribe(function (state) {
     todos = state.todos[key];
   });
   return todos;
 }
开发者ID:tedliang,项目名称:angular2-webpack-starter,代码行数:7,代码来源:todos.actions.ts

示例2: ngOnInit

  ngOnInit() {
    console.log("test");
    
    this.member = this.store.select(getMember);
    this.member.subscribe((member)=>{
      console.log("this.member$:::",member);
    });

    this.store.pipe(select(getMember)).subscribe((state)=>{
        console.log("pipe filter subscibe",state);
    });

    
    this.store.subscribe((state)=>{
      console.log("insider sub",state);
      //console.log("insider sub",this.store.select(getMember));
      //this.member = state.family.member;
    })
    
    //this.store.dispatch({type:'UPDATE_MEMBER',payload:{member:'Father'}});

    //console.log("Store Data:::",this.store.select<AppState>(state=>state.appState.member));

    /*this.store.select<AppState>((state:AppState)=>{
      console.log("State Obj",state);
      return state.appState.member;
    });*/
    
  }
开发者ID:nvignesh86,项目名称:AngularJs,代码行数:29,代码来源:family.component.ts

示例3: getVisibilityFilter

 getVisibilityFilter(): string {
   let filter;
   this.store.subscribe(function (state) {
     filter = state.visibilityFilter;
   });
   return filter;
 }
开发者ID:tedliang,项目名称:angular2-webpack-starter,代码行数:7,代码来源:todos.actions.ts

示例4: constructor

  constructor(private state: CoreStateService, private _store: Store<EpublicState>) {

    this._store.subscribe( x => {
      console.log( "EPUB STATE:" );
      console.log( mutable( x ) );
    } )

  }
开发者ID:drew-moore,项目名称:universal-starter,代码行数:8,代码来源:epublic.container.ts

示例5: constructor

  constructor(private store: Store<ApplicationState>) {

    this.participantNames$ = store.select(messageParticipantNamesSelector);

    this.messages$ = store.select(messagesSelector);

    store.subscribe(state => this.uiState = Object.assign({}, state.uiState));
  }
开发者ID:MidoShahin,项目名称:Chat-App-using-ngrx-store,代码行数:8,代码来源:message-section.component.ts

示例6: constructor

	constructor(private _store: Store<AppStore>) {
		
		//names is our reducer
		this.name$ = _store.select('names');

		//this is the typesafe equivalent of the line above
		//this.name$ = _store.select(state => state.names);

		_store.subscribe(state => console.log(state));
	}
开发者ID:ajpaul,项目名称:ng2-test-with-routing,代码行数:10,代码来源:name.ts

示例7: it

  it('should load the store eagerly', () => {
    let error = false;

    try {
      let store = TestBed.get(Store);
      store.subscribe();
    } catch (e) {
      error = true;
    }

    expect(error).toBeFalsy();
  });
开发者ID:AlexChar,项目名称:platform,代码行数:12,代码来源:integration.spec.ts

示例8: constructor

 constructor(
     store: Store<AppState>,
     stateResolver: StateResolverService
 ) {
     stateResolver.getState().subscribe((state: AppState) => {
         if (state) {
             store.dispatch({ type: 'SET_NEW_STATE', payload: state });
             const path = decodeURI(state.router.path);
             store.dispatch(replace(path));
         }
     });
     store.subscribe(s => stateResolver.saveState(s));
 }
开发者ID:Le0Michine,项目名称:Messanger,代码行数:13,代码来源:app.module.ts

示例9: provideStore

import {Tweet} from "./entities/tweet.entity";
import {ApplicationState} from "./applicationState";
provideStore(rootReducer);
let dispatcher: Dispatcher = new Dispatcher();
let reducers: any = combineReducers(rootReducer);
let reducer: Reducer = new Reducer(dispatcher, reducers);
let store: Store<{}> = new Store<ApplicationState>(dispatcher,
    new Reducer(dispatcher, reducers),
    new State<ApplicationState>(undefined, dispatcher, reducer),
    undefined
);
store.dispatch({type: Dispatcher.INIT});

store.subscribe((state: ApplicationState) => {
    console.log("tweets ", state.tweets);
    console.log("topbarCollapsed", state.topbarCollapsed);
    console.log("sidebarCollapsed", state.sidebarCollapsed);
});

debugger;

store.dispatch({type: TOGGLE_TOPBAR});

debugger;

store.dispatch({type: TOGGLE_TOPBAR});

debugger;

store.dispatch(
    {
开发者ID:KwintenP,项目名称:jsbe_talk,代码行数:31,代码来源:index.ts


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