本文整理汇总了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));
}