• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript store.Store类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript store.StoreModule类代码示例发布时间:2022-05-28
下一篇:
TypeScript store.ScannedActionsSubject类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap