phecda-vue 3.0.0-beta.20 → 3.0.0-beta.21
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/index.d.ts +3 -2
- package/dist/index.js +20 -0
- package/dist/index.mjs +20 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { Ref, App, UnwrapNestedRefs } from 'vue';
|
|
2
|
+
import { Ref, App, UnwrapNestedRefs, WatchOptions } from 'vue';
|
|
3
3
|
import { Construct, Events } from 'phecda-web';
|
|
4
4
|
export * from 'phecda-web';
|
|
5
5
|
|
|
@@ -62,5 +62,6 @@ declare function useEvent<Key extends keyof Events>(eventName: Key, cb: (event:
|
|
|
62
62
|
declare function initialize<M extends Construct>(model: M, deleteOtherProperty?: boolean): InstanceType<M> | void;
|
|
63
63
|
|
|
64
64
|
declare function Shallow(model: any): void;
|
|
65
|
+
declare function WatchEffect(option?: WatchOptions): (proto: any, key: string) => void;
|
|
65
66
|
|
|
66
|
-
export { DeepPartial, RE, Raw, RawSymbol, ReplaceInstanceValues, SchemaToObj, Shallow, createFilter, createPhecda, createSharedReactive, initialize, isObject, markRaw, mergeReactiveObjects, phecdaSymbol, useEvent, useO, usePatch, useR, useRaw, useV };
|
|
67
|
+
export { DeepPartial, RE, Raw, RawSymbol, ReplaceInstanceValues, SchemaToObj, Shallow, WatchEffect, createFilter, createPhecda, createSharedReactive, initialize, isObject, markRaw, mergeReactiveObjects, phecdaSymbol, useEvent, useO, usePatch, useR, useRaw, useV };
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ var src_exports = {};
|
|
|
24
24
|
__export(src_exports, {
|
|
25
25
|
RE: () => RE,
|
|
26
26
|
Shallow: () => Shallow,
|
|
27
|
+
WatchEffect: () => WatchEffect,
|
|
27
28
|
createFilter: () => createFilter,
|
|
28
29
|
createPhecda: () => createPhecda,
|
|
29
30
|
createSharedReactive: () => createSharedReactive,
|
|
@@ -322,14 +323,33 @@ __name(initialize, "initialize");
|
|
|
322
323
|
|
|
323
324
|
// src/decorator.ts
|
|
324
325
|
var import_phecda_web3 = require("phecda-web");
|
|
326
|
+
var import_vue5 = require("vue");
|
|
325
327
|
function Shallow(model) {
|
|
326
328
|
(0, import_phecda_web3.set)(model.prototype, "shallow", true);
|
|
327
329
|
}
|
|
328
330
|
__name(Shallow, "Shallow");
|
|
331
|
+
function WatchEffect(option) {
|
|
332
|
+
return (proto, key) => {
|
|
333
|
+
(0, import_phecda_web3.setStateKey)(proto, key);
|
|
334
|
+
let stopHandler;
|
|
335
|
+
(0, import_phecda_web3.setHandler)(proto, key, {
|
|
336
|
+
init(instance) {
|
|
337
|
+
if (typeof instance[key] !== "function")
|
|
338
|
+
throw new TypeError(" WatchEffect must decorate function");
|
|
339
|
+
stopHandler = (0, import_vue5.watchEffect)(instance[key].bind(instance), option);
|
|
340
|
+
},
|
|
341
|
+
unmount() {
|
|
342
|
+
return stopHandler?.();
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
__name(WatchEffect, "WatchEffect");
|
|
329
348
|
// Annotate the CommonJS export names for ESM import in node:
|
|
330
349
|
0 && (module.exports = {
|
|
331
350
|
RE,
|
|
332
351
|
Shallow,
|
|
352
|
+
WatchEffect,
|
|
333
353
|
createFilter,
|
|
334
354
|
createPhecda,
|
|
335
355
|
createSharedReactive,
|
package/dist/index.mjs
CHANGED
|
@@ -281,14 +281,33 @@ function initialize(model, deleteOtherProperty = true) {
|
|
|
281
281
|
__name(initialize, "initialize");
|
|
282
282
|
|
|
283
283
|
// src/decorator.ts
|
|
284
|
-
import { set } from "phecda-web";
|
|
284
|
+
import { set, setHandler, setStateKey } from "phecda-web";
|
|
285
|
+
import { watchEffect } from "vue";
|
|
285
286
|
function Shallow(model) {
|
|
286
287
|
set(model.prototype, "shallow", true);
|
|
287
288
|
}
|
|
288
289
|
__name(Shallow, "Shallow");
|
|
290
|
+
function WatchEffect(option) {
|
|
291
|
+
return (proto, key) => {
|
|
292
|
+
setStateKey(proto, key);
|
|
293
|
+
let stopHandler;
|
|
294
|
+
setHandler(proto, key, {
|
|
295
|
+
init(instance) {
|
|
296
|
+
if (typeof instance[key] !== "function")
|
|
297
|
+
throw new TypeError(" WatchEffect must decorate function");
|
|
298
|
+
stopHandler = watchEffect(instance[key].bind(instance), option);
|
|
299
|
+
},
|
|
300
|
+
unmount() {
|
|
301
|
+
return stopHandler?.();
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
__name(WatchEffect, "WatchEffect");
|
|
289
307
|
export {
|
|
290
308
|
RE,
|
|
291
309
|
Shallow,
|
|
310
|
+
WatchEffect,
|
|
292
311
|
createFilter,
|
|
293
312
|
createPhecda,
|
|
294
313
|
createSharedReactive,
|