本文整理匯總了TypeScript中@ngrx/store.select函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript select函數的具體用法?TypeScript select怎麽用?TypeScript select使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了select函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: create
async create(fileChanges: VcsFileChange[]): Promise<VcsItemCreateResult<NoteVcsItemComponent>> {
const usedFileChanges: VcsFileChange[] = [];
const refs: VcsItemRef<NoteVcsItemComponent>[] = [];
// Get notes first.
const notes = await toPromise(this.store.pipe(
select(state => state.note.collection.notes),
pipe(take(1)),
));
for (const note of notes) {
let index: number;
const willUseFileChanges: VcsFileChange[] = [];
// Note file
index = fileChanges.findIndex(change => change.absoluteFilePath === note.filePath);
if (index !== -1) {
willUseFileChanges.push(fileChanges[index]);
}
// Note content file
index = fileChanges.findIndex(change => change.absoluteFilePath === note.contentFilePath);
if (index !== -1) {
willUseFileChanges.push(fileChanges[index]);
}
if (willUseFileChanges.length > 0) {
const config: VcsItemConfig = {
title: note.title,
fileChanges: willUseFileChanges,
};
const ref = new VcsItemRef<NoteVcsItemComponent>(config);
ref.component = NoteVcsItemComponent;
usedFileChanges.push(...willUseFileChanges);
refs.push(ref);
}
}
return { refs, usedFileChanges };
}
示例2: hasSkilltree
hasSkilltree(id: string): Observable<boolean> {
return this.store.pipe(
select(state => {
return {loaded: Reducers.isLoaded(state), skilltrees: Reducers.getSkilltrees(state)};
}),
filter((combinedData) => {
return combinedData.loaded;
}),
map(combinedData => {
return combinedData.skilltrees;
}),
map(skilltrees => {
return !!skilltrees[id];
}),
take(1),
map(hasSkilltree => {
return hasSkilltree;
})
);
}
示例3: ngOnInit
ngOnInit() {
this.store.dispatch(new GetAppImagesAction());
this.app$ = this.store.pipe(select(getApp), filterNull());
this._sub = this.app$.pipe(first()).subscribe(app => this.store.dispatch(new GetQrCodeTemplatesAction({
appId: app.app_id,
backendId: app.backend_server,
})));
this.imagesInfo$ = this.store.select(getAppImages);
this.status$ = this.store.select(getAppImagesStatus);
this.generateStatus$ = this.store.select(getGenerateAppImagesStatus);
this.generateStatus$.subscribe(status => {
if (status.success) {
this.router.navigate([ '../' ], {
relativeTo: this.route,
queryParams: {
reloadImage: true,
},
});
}
});
}
示例4: it
it('should initialize properly', () => {
TestBed.configureTestingModule({
imports: [
StoreModule.forRoot(reducers, { initialState }),
StoreModule.forFeature('items', todos, {
initialState: featureInitialState,
}),
],
});
const store: Store<any> = TestBed.get(Store);
let expected = [
{
todos: initialState.todos,
visibilityFilter: initialState.visibilityFilter,
items: featureInitialState,
},
];
store.pipe(select(state => state)).subscribe(state => {
expect(state).toEqual(expected.shift());
});
});
示例5: constructor
/**
* Constructor
*
* @param {ChangeDetectorRef} _changeDetectorRef
* @param {FuseSidebarService} _fuseSidebarService
* @param {FuseTranslationLoaderService} _fuseTranslationLoaderService
* @param {MailNgrxService} _mailNgrxService
* @param {Store<MailAppState>} _store
*/
constructor(
private _changeDetectorRef: ChangeDetectorRef,
private _fuseSidebarService: FuseSidebarService,
private _fuseTranslationLoaderService: FuseTranslationLoaderService,
private _mailNgrxService: MailNgrxService,
private _store: Store<fromStore.MailAppState>
)
{
// Set the defaults
this.searchInput = new FormControl('');
this._fuseTranslationLoaderService.loadTranslations(english, turkish);
this.currentMail$ = this._store.pipe(select(fromStore.getCurrentMail));
this.mails$ = this._store.pipe(select(fromStore.getMailsArr));
this.folders$ = this._store.pipe(select(fromStore.getFoldersArr));
this.labels$ = this._store.pipe(select(fromStore.getLabelsArr));
this.selectedMailIds$ = this._store.pipe(select(fromStore.getSelectedMailIds));
this.searchText$ = this._store.pipe(select(fromStore.getSearchText));
this.mails = [];
this.selectedMailIds = [];
}
示例6: resolve
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Item> {
this.store.dispatch(new FindOneAction(route.params.id, route.params.podcastId));
return this.store.pipe(select(item), skip(1), take(1));
}
示例7: ngOnInit
ngOnInit() {
this.chartDetails$ = this.store.pipe(select(selectAppDetails));
}
示例8: constructor
constructor(private store: Store<fromBooks.State>) {
this.book$ = store.pipe(select(fromBooks.getSelectedBook));
this.isSelectedBookInCollection$ = store.pipe(
select(fromBooks.isSelectedBookInCollection)
);
}
示例9: getLinkTypes
get getLinkTypes(): Observable<LinkTypeUI[]> {
return this.store.pipe(
select(workItemDetailSelector),
select(state => state.linkType),
filter(lt => !!lt.length));
}
示例10: constructor
constructor(private store: Store<fromRoot.State>) {
this.article$ = store.pipe(select(fromArticles.getSelectedArticle));
}