@jucie.io/state 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Plugin.js +36 -0
- package/package.json +1 -1
package/dist/Plugin.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export class Plugin {
|
|
2
|
+
|
|
3
|
+
static name = null;
|
|
4
|
+
static options = {};
|
|
5
|
+
|
|
6
|
+
static configure(options) {
|
|
7
|
+
options = {...this.options, ...options};
|
|
8
|
+
return {
|
|
9
|
+
install: (state) => this.install(state, options),
|
|
10
|
+
name: this.name,
|
|
11
|
+
options
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static install(state, options) {
|
|
16
|
+
options = {...this.options, ...options};
|
|
17
|
+
const pluginInstance = new this(state, options);
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(pluginInstance, 'state', {
|
|
20
|
+
value: state,
|
|
21
|
+
writable: false,
|
|
22
|
+
configurable: false
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(pluginInstance, 'options', {
|
|
26
|
+
value: options,
|
|
27
|
+
writable: false,
|
|
28
|
+
configurable: false
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
return pluginInstance;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default Plugin;
|