aoye 0.0.47 → 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/index.umd.js CHANGED
@@ -719,6 +719,19 @@
719
719
  }
720
720
  }
721
721
  }
722
+ class NoopEffect {
723
+ constructor(callback) {
724
+ this.callback = callback;
725
+ const scope = new Scope(callback);
726
+ scope.get();
727
+ return scope;
728
+ }
729
+ }
730
+ const noopEffect = callback => {
731
+ const scope = new Scope(callback);
732
+ scope.get();
733
+ return scope;
734
+ };
722
735
  Scope.prototype.dispose = dispose;
723
736
 
724
737
  const rawToProxy = new WeakMap();
@@ -1264,6 +1277,10 @@
1264
1277
  };
1265
1278
  }
1266
1279
  }
1280
+ const DefaultCustomEffectOpt = {
1281
+ immediate: true,
1282
+ type: 'sync'
1283
+ };
1267
1284
  function effectUt(callback, depOrOpt, opt) {
1268
1285
  const hasDep = Array.isArray(depOrOpt);
1269
1286
  opt = hasDep ? opt || {} : depOrOpt || {};
@@ -1303,6 +1320,10 @@
1303
1320
  function effect(callback, depOrOpt, opt) {
1304
1321
  const hasDep = Array.isArray(depOrOpt);
1305
1322
  opt = hasDep ? opt || {} : depOrOpt || {};
1323
+ opt = {
1324
+ ...DefaultCustomEffectOpt,
1325
+ ...opt
1326
+ };
1306
1327
  const scheduleType = EffectStrType2Enum[opt.type];
1307
1328
  if (!hasDep) {
1308
1329
  const ef = new Effect(callback, scheduleType);
@@ -1319,7 +1340,8 @@
1319
1340
  }));
1320
1341
  const ef = new Effect(eff => {
1321
1342
  for (let i = 0; i < deps.length; i++) {
1322
- const value = deps[i].get();
1343
+ const dep = deps[i];
1344
+ const value = typeof dep === 'function' ? dep() : dep.get();
1323
1345
  vs[i].old = vs[i].val;
1324
1346
  vs[i].val = value;
1325
1347
  }
@@ -1349,6 +1371,7 @@
1349
1371
  exports.EffectStrType2Enum = EffectStrType2Enum;
1350
1372
  exports.IsStore = IsStore;
1351
1373
  exports.Keys = Keys;
1374
+ exports.NoopEffect = NoopEffect;
1352
1375
  exports.ScheduleStatus = ScheduleStatus;
1353
1376
  exports.ScheduleType = ScheduleType;
1354
1377
  exports.Scope = Scope;
@@ -1367,6 +1390,7 @@
1367
1390
  exports.ide = ide;
1368
1391
  exports.macro = macro;
1369
1392
  exports.micro = micro;
1393
+ exports.noopEffect = noopEffect;
1370
1394
  exports.now = now;
1371
1395
  exports.runWithPulling = runWithPulling;
1372
1396
  exports.scope = scope;