mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Roman <ixrock@gmail.com> Co-authored-by: Jim Ehrismann <40840436+jim-docker@users.noreply.github.com>
18 lines
370 B
TypeScript
18 lines
370 B
TypeScript
// Base class for extensions-api registries
|
|
import { observable } from "mobx";
|
|
|
|
export class BaseRegistry<T = any> {
|
|
protected items = observable<T>([], { deep: false });
|
|
|
|
getItems(): T[] {
|
|
return this.items.toJS();
|
|
}
|
|
|
|
add(item: T) {
|
|
this.items.push(item);
|
|
return () => {
|
|
this.items.remove(item); // works because of {deep: false};
|
|
}
|
|
}
|
|
}
|