aoye 0.0.47 → 0.0.49
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/aoye.cjs.js +25 -1
- package/dist/aoye.cjs.js.map +1 -1
- package/dist/aoye.esm.js +24 -2
- package/dist/aoye.esm.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.umd.js +25 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/aoye.cjs.js
CHANGED
|
@@ -717,6 +717,19 @@ class Scope {
|
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
|
+
class NoopEffect {
|
|
721
|
+
constructor(callback) {
|
|
722
|
+
this.callback = callback;
|
|
723
|
+
const scope = new Scope(callback);
|
|
724
|
+
scope.get();
|
|
725
|
+
return scope;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
const noopEffect = callback => {
|
|
729
|
+
const scope = new Scope(callback);
|
|
730
|
+
scope.get();
|
|
731
|
+
return scope;
|
|
732
|
+
};
|
|
720
733
|
Scope.prototype.dispose = dispose;
|
|
721
734
|
|
|
722
735
|
const rawToProxy = new WeakMap();
|
|
@@ -1262,6 +1275,10 @@ function $(data) {
|
|
|
1262
1275
|
};
|
|
1263
1276
|
}
|
|
1264
1277
|
}
|
|
1278
|
+
const DefaultCustomEffectOpt = {
|
|
1279
|
+
immediate: true,
|
|
1280
|
+
type: 'sync'
|
|
1281
|
+
};
|
|
1265
1282
|
function effectUt(callback, depOrOpt, opt) {
|
|
1266
1283
|
const hasDep = Array.isArray(depOrOpt);
|
|
1267
1284
|
opt = hasDep ? opt || {} : depOrOpt || {};
|
|
@@ -1301,6 +1318,10 @@ function effectUt(callback, depOrOpt, opt) {
|
|
|
1301
1318
|
function effect(callback, depOrOpt, opt) {
|
|
1302
1319
|
const hasDep = Array.isArray(depOrOpt);
|
|
1303
1320
|
opt = hasDep ? opt || {} : depOrOpt || {};
|
|
1321
|
+
opt = {
|
|
1322
|
+
...DefaultCustomEffectOpt,
|
|
1323
|
+
...opt
|
|
1324
|
+
};
|
|
1304
1325
|
const scheduleType = EffectStrType2Enum[opt.type];
|
|
1305
1326
|
if (!hasDep) {
|
|
1306
1327
|
const ef = new Effect(callback, scheduleType);
|
|
@@ -1317,7 +1338,8 @@ function effect(callback, depOrOpt, opt) {
|
|
|
1317
1338
|
}));
|
|
1318
1339
|
const ef = new Effect(eff => {
|
|
1319
1340
|
for (let i = 0; i < deps.length; i++) {
|
|
1320
|
-
const
|
|
1341
|
+
const dep = deps[i];
|
|
1342
|
+
const value = typeof dep === 'function' ? dep() : dep.get();
|
|
1321
1343
|
vs[i].old = vs[i].val;
|
|
1322
1344
|
vs[i].val = value;
|
|
1323
1345
|
}
|
|
@@ -1347,6 +1369,7 @@ exports.Effect = Effect;
|
|
|
1347
1369
|
exports.EffectStrType2Enum = EffectStrType2Enum;
|
|
1348
1370
|
exports.IsStore = IsStore;
|
|
1349
1371
|
exports.Keys = Keys;
|
|
1372
|
+
exports.NoopEffect = NoopEffect;
|
|
1350
1373
|
exports.ScheduleStatus = ScheduleStatus;
|
|
1351
1374
|
exports.ScheduleType = ScheduleType;
|
|
1352
1375
|
exports.Scope = Scope;
|
|
@@ -1365,6 +1388,7 @@ exports.getPulling = getPulling;
|
|
|
1365
1388
|
exports.ide = ide;
|
|
1366
1389
|
exports.macro = macro;
|
|
1367
1390
|
exports.micro = micro;
|
|
1391
|
+
exports.noopEffect = noopEffect;
|
|
1368
1392
|
exports.now = now;
|
|
1369
1393
|
exports.runWithPulling = runWithPulling;
|
|
1370
1394
|
exports.scope = scope;
|