本文整理匯總了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;
}
示例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;
});*/
}
示例3: getVisibilityFilter
getVisibilityFilter(): string {
let filter;
this.store.subscribe(function (state) {
filter = state.visibilityFilter;
});
return filter;
}
示例4: constructor
constructor(private state: CoreStateService, private _store: Store<EpublicState>) {
this._store.subscribe( x => {
console.log( "EPUB STATE:" );
console.log( mutable( x ) );
} )
}
示例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));
}
示例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));
}
示例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();
});
示例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));
}
示例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(
{