當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。