mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-05 05:18:34 +08:00
暴露store清理api
This commit is contained in:
parent
67fe342b73
commit
737696f81c
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import qs from 'qs';
|
||||
import {RendererStore, IRendererStore, IIRendererStore} from './store/index';
|
||||
import {getEnv} from 'mobx-state-tree';
|
||||
import {getEnv, destroy} from 'mobx-state-tree';
|
||||
import {Location} from 'history';
|
||||
import {wrapFetcher} from './utils/api';
|
||||
import {
|
||||
@ -961,12 +961,19 @@ export function render(
|
||||
);
|
||||
}
|
||||
|
||||
export function clearStoresCache(sessions?: Array<string>) {
|
||||
if (Array.isArray(sessions) && sessions.length) {
|
||||
sessions.forEach(key => delete stores[key]);
|
||||
} else {
|
||||
stores = {};
|
||||
export function clearStoresCache(
|
||||
sessions: Array<string> | string = Object.keys(stores)
|
||||
) {
|
||||
if (!Array.isArray(sessions)) {
|
||||
sessions = [sessions];
|
||||
}
|
||||
|
||||
sessions.forEach(key => {
|
||||
const store = stores[key];
|
||||
delete stores[key];
|
||||
|
||||
store && destroy(store);
|
||||
});
|
||||
}
|
||||
|
||||
let cache: {[propName: string]: RendererConfig} = {};
|
||||
|
@ -10,7 +10,8 @@ import {
|
||||
Renderer,
|
||||
getRendererByName,
|
||||
resolveRenderer,
|
||||
filterSchema
|
||||
filterSchema,
|
||||
clearStoresCache
|
||||
} from './factory';
|
||||
import {wrapFetcher, buildApi} from './utils/api';
|
||||
import {filter, reigsterTplEnginer, evalExpression} from './utils/tpl';
|
||||
@ -195,6 +196,7 @@ const classPrefix = getClassPrefix();
|
||||
|
||||
export {
|
||||
render,
|
||||
clearStoresCache,
|
||||
Renderer,
|
||||
FormItem,
|
||||
OptionsControl,
|
||||
|
Loading…
Reference in New Issue
Block a user