本文整理汇总了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(
{