plug-code 1.1.5 → 1.1.6
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/package.json +1 -1
- package/src/core/plcAPI.tsx +12 -0
- package/src/plug-code.tsx +1 -3
package/package.json
CHANGED
package/src/core/plcAPI.tsx
CHANGED
|
@@ -51,6 +51,18 @@ export class PlcAPI<S extends ObjectType> {
|
|
|
51
51
|
return this;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
replace<K extends string>(key: K & "root", data: Partial<any>, slot?: string) {
|
|
55
|
+
const currentSub = this.substores.get(key) || {};
|
|
56
|
+
const newSub = { ...currentSub, ...data };
|
|
57
|
+
|
|
58
|
+
this.substores.set(key, newSub);
|
|
59
|
+
this.store.set(key as any, newSub);
|
|
60
|
+
|
|
61
|
+
if (slot) {
|
|
62
|
+
this.invalidate(slot);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
54
66
|
register(slot: SlotKey, node: () => React.ReactNode): void;
|
|
55
67
|
register<K extends string>(slot: SlotKey, node: (data: any) => React.ReactNode, dependencyKey: K): void;
|
|
56
68
|
register(slot: SlotKey, node: (data?: any) => React.ReactNode, dependencyKey?: string) {
|
package/src/plug-code.tsx
CHANGED
|
@@ -39,9 +39,7 @@ export function createPlugAndCode<S extends ObjectType>(
|
|
|
39
39
|
}, []);
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
42
|
-
api.
|
|
43
|
-
Object.assign(draft, initialProps);
|
|
44
|
-
});
|
|
42
|
+
api.replace("root", initialProps)
|
|
45
43
|
}, [initialProps, api]);
|
|
46
44
|
|
|
47
45
|
const useSelector = <Result,>(selector: (state: any) => Result): Result => {
|