aoye 0.0.46 → 0.0.48
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 +38 -8
- package/dist/aoye.cjs.js.map +1 -1
- package/dist/aoye.esm.js +36 -9
- package/dist/aoye.esm.js.map +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.umd.js +38 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/aoye.cjs.js
CHANGED
|
@@ -25,6 +25,12 @@ let ScheduleType = function (ScheduleType) {
|
|
|
25
25
|
ScheduleType[ScheduleType["Post"] = 8] = "Post";
|
|
26
26
|
return ScheduleType;
|
|
27
27
|
}({});
|
|
28
|
+
const EffectStrType2Enum = {
|
|
29
|
+
sync: ScheduleType.Sync,
|
|
30
|
+
pre: ScheduleType.Pre,
|
|
31
|
+
render: ScheduleType.Render,
|
|
32
|
+
post: ScheduleType.Post
|
|
33
|
+
};
|
|
28
34
|
let ScheduleStatus = function (ScheduleStatus) {
|
|
29
35
|
ScheduleStatus[ScheduleStatus["Idle"] = 0] = "Idle";
|
|
30
36
|
ScheduleStatus[ScheduleStatus["Ready"] = 1] = "Ready";
|
|
@@ -711,6 +717,19 @@ class Scope {
|
|
|
711
717
|
}
|
|
712
718
|
}
|
|
713
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
|
+
};
|
|
714
733
|
Scope.prototype.dispose = dispose;
|
|
715
734
|
|
|
716
735
|
const rawToProxy = new WeakMap();
|
|
@@ -1256,14 +1275,16 @@ function $(data) {
|
|
|
1256
1275
|
};
|
|
1257
1276
|
}
|
|
1258
1277
|
}
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1278
|
+
const DefaultCustomEffectOpt = {
|
|
1279
|
+
immediate: true,
|
|
1280
|
+
type: 'sync'
|
|
1281
|
+
};
|
|
1262
1282
|
function effectUt(callback, depOrOpt, opt) {
|
|
1263
1283
|
const hasDep = Array.isArray(depOrOpt);
|
|
1264
1284
|
opt = hasDep ? opt || {} : depOrOpt || {};
|
|
1285
|
+
const scheduleType = EffectStrType2Enum[opt.type];
|
|
1265
1286
|
if (!hasDep) {
|
|
1266
|
-
const ef = new Effect(callback,
|
|
1287
|
+
const ef = new Effect(callback, scheduleType);
|
|
1267
1288
|
const run = ef.dispose.bind(ef);
|
|
1268
1289
|
run.ins = ef;
|
|
1269
1290
|
return run;
|
|
@@ -1289,7 +1310,7 @@ function effectUt(callback, depOrOpt, opt) {
|
|
|
1289
1310
|
eff.state &= -257;
|
|
1290
1311
|
}
|
|
1291
1312
|
mounted = true;
|
|
1292
|
-
},
|
|
1313
|
+
}, scheduleType);
|
|
1293
1314
|
const run = ef.dispose.bind(ef);
|
|
1294
1315
|
run.ins = ef;
|
|
1295
1316
|
return run;
|
|
@@ -1297,8 +1318,13 @@ function effectUt(callback, depOrOpt, opt) {
|
|
|
1297
1318
|
function effect(callback, depOrOpt, opt) {
|
|
1298
1319
|
const hasDep = Array.isArray(depOrOpt);
|
|
1299
1320
|
opt = hasDep ? opt || {} : depOrOpt || {};
|
|
1321
|
+
opt = {
|
|
1322
|
+
...DefaultCustomEffectOpt,
|
|
1323
|
+
...opt
|
|
1324
|
+
};
|
|
1325
|
+
const scheduleType = EffectStrType2Enum[opt.type];
|
|
1300
1326
|
if (!hasDep) {
|
|
1301
|
-
const ef = new Effect(callback,
|
|
1327
|
+
const ef = new Effect(callback, scheduleType);
|
|
1302
1328
|
return ef;
|
|
1303
1329
|
}
|
|
1304
1330
|
let mounted = false;
|
|
@@ -1312,7 +1338,8 @@ function effect(callback, depOrOpt, opt) {
|
|
|
1312
1338
|
}));
|
|
1313
1339
|
const ef = new Effect(eff => {
|
|
1314
1340
|
for (let i = 0; i < deps.length; i++) {
|
|
1315
|
-
const
|
|
1341
|
+
const dep = deps[i];
|
|
1342
|
+
const value = typeof dep === 'function' ? dep() : dep.get();
|
|
1316
1343
|
vs[i].old = vs[i].val;
|
|
1317
1344
|
vs[i].val = value;
|
|
1318
1345
|
}
|
|
@@ -1322,7 +1349,7 @@ function effect(callback, depOrOpt, opt) {
|
|
|
1322
1349
|
eff.state &= -257;
|
|
1323
1350
|
}
|
|
1324
1351
|
mounted = true;
|
|
1325
|
-
},
|
|
1352
|
+
}, scheduleType);
|
|
1326
1353
|
return ef;
|
|
1327
1354
|
}
|
|
1328
1355
|
function scope(...args) {
|
|
@@ -1339,8 +1366,10 @@ function scope(...args) {
|
|
|
1339
1366
|
exports.$ = $;
|
|
1340
1367
|
exports.Computed = Computed;
|
|
1341
1368
|
exports.Effect = Effect;
|
|
1369
|
+
exports.EffectStrType2Enum = EffectStrType2Enum;
|
|
1342
1370
|
exports.IsStore = IsStore;
|
|
1343
1371
|
exports.Keys = Keys;
|
|
1372
|
+
exports.NoopEffect = NoopEffect;
|
|
1344
1373
|
exports.ScheduleStatus = ScheduleStatus;
|
|
1345
1374
|
exports.ScheduleType = ScheduleType;
|
|
1346
1375
|
exports.Scope = Scope;
|
|
@@ -1359,6 +1388,7 @@ exports.getPulling = getPulling;
|
|
|
1359
1388
|
exports.ide = ide;
|
|
1360
1389
|
exports.macro = macro;
|
|
1361
1390
|
exports.micro = micro;
|
|
1391
|
+
exports.noopEffect = noopEffect;
|
|
1362
1392
|
exports.now = now;
|
|
1363
1393
|
exports.runWithPulling = runWithPulling;
|
|
1364
1394
|
exports.scope = scope;
|