當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。