本文整理汇总了TypeScript中@ngrx/store.Store类的典型用法代码示例。如果您正苦于以下问题:TypeScript Store类的具体用法?TypeScript Store怎么用?TypeScript Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Store类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(private store$: Store<AppState>) {
this.counter$ = store$.select('counter');
}
示例2: constructor
constructor(private store: Store<any>) {
this.names = store.select('names');
}
示例3: hasHotelInStore
hasHotelInStore(id: number){
return this.store.let(hasHotel(id)).take(1);
}
示例4: describe
describe('EpisodesComponent', () => {
let component: EpisodesComponent;
let fixture: ComponentFixture<EpisodesComponent>;
let el: DebugElement;
let store: Store<PodcastState>;
let datePipe: DatePipe;
beforeEach(
async(() => {
TestBed.configureTestingModule({
declarations: [EpisodesComponent],
imports: [
MatListModule,
MatPaginatorModule,
RouterTestingModule.withRoutes([]),
StoreModule.forRoot({}),
StoreModule.forFeature('podcast', fromPodcast.reducer),
RouterTestingModule
],
}).compileComponents();
datePipe = new DatePipe('en-US');
})
);
beforeEach(async () => {
store = TestBed.get(Store);
spyOn(store, 'dispatch').and.callThrough();
});
beforeEach(async () => {
store.dispatch(new FindItemsByPodcastsAndPageSuccessAction(items));
fixture = TestBed.createComponent(EpisodesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
el = fixture.debugElement;
await fixture.whenStable();
});
it('should create', () => {
/* Given */
/* When */
/* Then */
expect(component).toBeTruthy();
});
it('should have coherent number of items', () => {
/* Given */
/* When */
const itemsElement = el.queryAll(By.css('[mat-list-item]'));
/* Then */
expect(itemsElement.length).toEqual(10);
});
it('should have each line with cover', () => {
/* Given */
const coversExpected = items.content.map(v => v.cover.url);
/* When */
const coversUrl = el.queryAll(By.css('img')).map(v => v.properties.src);
/* Then */
expect(coversExpected).toEqual(coversUrl);
});
it('should have each line with title', () => {
/* Given */
const titleExpected = items.content.map(v => v.title);
/* When */
const titles = el.queryAll(By.css('h3[matLine]')).map(asText);
/* Then */
expect(titleExpected).toEqual(titles);
});
it('should have each line with date', () => {
/* Given */
const dateExpected = items.content.map(v => v.pubDate).map(v => datePipe.transform(v, 'dd/MM/yyyy Ă HH:mm'));
/* When */
const dates = el.queryAll(By.css('p[matLine]')).map(asText);
/* Then */
expect(dateExpected).toEqual(dates);
});
function asText(v: DebugElement) {
return v.nativeElement.textContent.trim();
}
});
示例5: ngOnInit
ngOnInit() {
this.shoppingListState = this.store.select('shoppingList');
}
示例6:
this.usersService.getUsers().subscribe(users => {
this.users = users;
this.store.dispatch({type: INIT_USERS, payload: this.users});
});
示例7: ngOnInit
ngOnInit() {
this.isFetching$ = this.store.select(fromCustomer.getCustomersLoading);
this.customers$ = this.store.select(fromCustomer.getCustomers);
this.store.dispatch(new customerActions.LoadAction());
}
示例8: clearFlashMessage
clearFlashMessage() {
this.store.dispatch(new ClearFlashMessage())
}
示例9: toggle
toggle(node: TreeNode){
this._store.dispatch({type: TOGGLE_NODE, payload: node.name});
}
示例10:
.do(action => this.store.dispatch(action))