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


TypeScript store.Store类代码示例

本文整理汇总了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');
 }
开发者ID:iproduct,项目名称:course-angular,代码行数:3,代码来源:app.component.ts

示例2: constructor

 constructor(private store: Store<any>) {
   this.names = store.select('names');
 }  
开发者ID:krzysztofsaja,项目名称:angular2-seed-advanced,代码行数:3,代码来源:name-list.service.ts

示例3: hasHotelInStore

 hasHotelInStore(id: number){
   return this.store.let(hasHotel(id)).take(1);
 }
开发者ID:joachimprinzbach,项目名称:ng2-camp,代码行数:3,代码来源:hotelExistsGuard.ts

示例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();
	}
});
开发者ID:davinkevin,项目名称:Podcast-Server,代码行数:87,代码来源:episodes.component.spec.ts

示例5: ngOnInit

 ngOnInit() {
   this.shoppingListState = this.store.select('shoppingList');
 }
开发者ID:Knox316,项目名称:Angular7Training,代码行数:3,代码来源:shopping-list.component.ts

示例6:

 this.usersService.getUsers().subscribe(users => {
     this.users = users;
     this.store.dispatch({type: INIT_USERS, payload: this.users});
 });
开发者ID:dan-lyn,项目名称:angularjs-playground,代码行数:4,代码来源:manage.component.ts

示例7: ngOnInit

 ngOnInit() {
   this.isFetching$ = this.store.select(fromCustomer.getCustomersLoading);
   this.customers$ = this.store.select(fromCustomer.getCustomers);
   this.store.dispatch(new customerActions.LoadAction());
 }
开发者ID:Hagendorn,项目名称:billing-ng2,代码行数:5,代码来源:customer-list.component.ts

示例8: clearFlashMessage

 clearFlashMessage() {
   this.store.dispatch(new ClearFlashMessage())
 }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:3,代码来源:home.component.ts

示例9: toggle

   toggle(node: TreeNode){
     this._store.dispatch({type: TOGGLE_NODE, payload: node.name});
 }
开发者ID:stefanos-,项目名称:angular-cli-sample-dynamic-forms-ngrx-store,代码行数:3,代码来源:tree-view.component.ts

示例10:

 .do(action => this.store.dispatch(action))
开发者ID:joachimprinzbach,项目名称:ng2-camp,代码行数:1,代码来源:hotelExistsGuard.ts


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