import { action, observable } from 'mobx'; export default class BasicStore { @observable isLoading = observable.map({ }); @action changeLoadingStatus (loadingType, type) { this.isLoading.set(loadingType, type); } } // 初始化loading export function initLoading(target, key, descriptor) { const oldValue = descriptor.value; descriptor.value = async function(...args) { this.changeLoadingStatus(key, true); let res; try { res = await oldValue.apply(this, args); } catch (error) { // 做一些错误上报之类的处理 throw error; } finally { this.changeLoadingStatus(key, false); } return res; }; return descriptor; }
Copyright © 2023 leiyu.cn. All Rights Reserved. 磊宇云计算 版权所有 许可证编号:B1-20233142/B2-20230630 山东磊宇云计算有限公司 鲁ICP备2020045424号
磊宇云计算致力于以最 “绿色节能” 的方式,让每一位上云的客户成为全球绿色节能和降低碳排放的贡献者