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


TypeScript StateContext.patchState方法代码示例

本文整理汇总了TypeScript中@ngxs/store.StateContext.patchState方法的典型用法代码示例。如果您正苦于以下问题:TypeScript StateContext.patchState方法的具体用法?TypeScript StateContext.patchState怎么用?TypeScript StateContext.patchState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@ngxs/store.StateContext的用法示例。


在下文中一共展示了StateContext.patchState方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: updateSelectedStorage

 @Action(BrowseStoragesSelectStorage)
 updateSelectedStorage(ctx: StateContext<BrowseStoragesStateModel>, {payload}: BrowseStoragesSelectStorage) {
     ctx.patchState({
         ...ctx.getState(),
         selectedStorage: payload
     });
 }
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:7,代码来源:browse-storages.state.model.ts

示例2: toggleStorageSearchInput

 @Action(BrowseStoragesToggleStoragesSearchInput)
 toggleStorageSearchInput(ctx: StateContext<BrowseStoragesStateModel>) {
     ctx.patchState({
         ...ctx.getState(),
         showStoragesSearch: !ctx.getState().showStoragesSearch
     });
 }
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:7,代码来源:browse-storages.state.model.ts

示例3: tap

 tap((storages: StorageEntity[]) => {
     const state = ctx.getState();
     ctx.patchState({
         ...state,
         storages: storages,
         loadingStorages: false,
     });
 })
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:8,代码来源:browse-storages.state.model.ts

示例4: deleteStorage

 @Action(BrowseStoragesDeleteStorage)
 deleteStorage(ctx: StateContext<BrowseStoragesStateModel>, {id}: BrowseStoragesDeleteStorage) {
     ctx.patchState({
         ...ctx.getState(),
         storages: [
             ...ctx.getState().storages.filter((s) => s.id !== id)
         ]
     });
 }
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:9,代码来源:browse-storages.state.model.ts

示例5: addStorage

 @Action(BrowseStoragesAddStorage)
 addStorage(ctx: StateContext<BrowseStoragesStateModel>, {storage}: BrowseStoragesAddStorage) {
     ctx.patchState({
         ...ctx.getState(),
         storages: [
             ...ctx.getState().storages,
             storage
         ].sort((a, b) => a.id.toLocaleLowerCase().localeCompare(b.id.toLocaleLowerCase()))
     });
 }
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:10,代码来源:browse-storages.state.model.ts

示例6: login

 @Action(LoginAction)
 login(ctx: StateContext<SessionStateModel>, {payload}: LoginAction) {
     ctx.patchState({state: 'pending'});
     return this.auth.login(payload).pipe(
         tap((state: SessionStateModel) => {
             if (state.state === 'authenticated') {
                 localStorage.setItem('session', JSON.stringify(state));
             }
             ctx.setState(state);
         }),
         catchError((state: any, caught) => {
             ctx.patchState(defaultSessionState);
             console.log('Fatal authentication error!', state, caught);
             return of(null);
         })
     );
 }
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:17,代码来源:session.state.ts

示例7: loadRepositoriesOnStorageChange

    @Action(BrowseStoragesSelectStorage)
    loadRepositoriesOnStorageChange(ctx: StateContext<BrowseStoragesStateModel>, {payload}: BrowseStoragesSelectStorage) {
        const loadRepositories = payload !== null;

        ctx.patchState({
            selectedStorage: payload,
            loadingRepositories: loadRepositories
        });

        if (loadRepositories) {
            return this.storageService
                .getStorage(payload)
                .pipe(
                    catchError((error: ApiResponse) => {
                        if (error.message.length > 0 && error.message.match(/storage/i)) {
                            this.notify.warning('Storage "' + payload + '" was not found.');
                            ctx.dispatch(new Navigate(['/admin/storages']));
                        } else {
                            this.notify.error('Could not retrieve repositories ' + payload + '!');
                            console.error('Could not retrieve repositories  for storage ' + payload + '!', error);
                        }
                        return of(error);
                    }),
                    tap((storageEntity: StorageEntity) => {
                        let repositories = [];
                        if (storageEntity instanceof StorageEntity) {
                            // Add storageId to Repository (makes life easier afterwards in the UI)
                            repositories = storageEntity.repositories.map((repo) => {
                                repo.storageId = payload;
                                return repo;
                            }).sort((a, b) => a.id.toLocaleLowerCase().localeCompare(b.id.toLocaleLowerCase()));
                        }

                        ctx.patchState({
                            ...ctx.getState(),
                            repositories: repositories,
                            loadingRepositories: false
                        });
                    })
                );
        }
    }
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:42,代码来源:browse-storages.state.model.ts

示例8: invalidCredentialsSessionState

 @Action(InvalidCredentialsAction)
 invalidCredentialsSessionState(ctx: StateContext<SessionStateModel>) {
     ctx.patchState({state: 'invalid.credentials'});
 }
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:4,代码来源:session.state.ts

示例9: catchError

 catchError((state: any, caught) => {
     ctx.patchState(defaultSessionState);
     console.log('Fatal authentication error!', state, caught);
     return of(null);
 })
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:5,代码来源:session.state.ts


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