Skip to content

Commit 94fb7c0

Browse files
Merge pull request #46 from webzard-io/xingyu/plugin
feat: 🎸 add loadPlugins to globalstore
2 parents 19cb2da + 7dfd366 commit 94fb7c0

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/global-store.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface GlobalStoreInitParams {
2727
prefix?: string;
2828
fieldManager?: string;
2929
kubeApiTimeout?: false | number;
30+
plugins?: IProviderPlugin[];
3031
}
3132
export interface CancelQueriesParams {
3233
queryKeys?: string[];
@@ -167,8 +168,14 @@ export class GlobalStore {
167168

168169
init(params: GlobalStoreInitParams) {
169170
this.destroy();
170-
const { apiUrl, watchWsApiUrl, prefix, fieldManager, kubeApiTimeout } =
171-
params;
171+
const {
172+
apiUrl,
173+
watchWsApiUrl,
174+
prefix,
175+
fieldManager,
176+
kubeApiTimeout,
177+
plugins,
178+
} = params;
172179
this.store = new Map();
173180
this.subscribers = new Map();
174181
this.stopWatchHandlers = new Map();
@@ -178,9 +185,15 @@ export class GlobalStore {
178185
this.prefix = prefix;
179186
this.fieldManager = fieldManager;
180187
this._kubeApiTimeout = kubeApiTimeout;
181-
this.plugins.forEach(plugin => plugin.init(this));
188+
this.loadPlugins(plugins);
189+
}
190+
loadPlugins(plugins?: IProviderPlugin[]) {
191+
if (plugins) {
192+
this.destroy();
193+
this.plugins = plugins;
194+
this.plugins.forEach(plugin => plugin.init(this));
195+
}
182196
}
183-
184197
private async processList(list: UnstructuredList) {
185198
let nextList = list;
186199
nextList.items.forEach(item => {

0 commit comments

Comments
 (0)