ywana-core8 0.0.989 → 0.0.991

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.
@@ -5342,6 +5342,20 @@ var Wizard = function Wizard(props) {
5342
5342
  * Task Context
5343
5343
  */
5344
5344
 
5345
+ function _catch$5(body, recover) {
5346
+ try {
5347
+ var result = body();
5348
+ } catch (e) {
5349
+ return recover(e);
5350
+ }
5351
+ if (result && result.then) {
5352
+ return result.then(void 0, recover);
5353
+ }
5354
+ return result;
5355
+ } /**
5356
+ * Task Provider
5357
+ */
5358
+
5345
5359
  function _settle(pact, state, value) {
5346
5360
  if (!pact.s) {
5347
5361
  if (value instanceof _Pact) {
@@ -5361,14 +5375,12 @@ function _settle(pact, state, value) {
5361
5375
  }
5362
5376
  pact.s = state;
5363
5377
  pact.v = value;
5364
- const observer = pact.o;
5378
+ var observer = pact.o;
5365
5379
  if (observer) {
5366
5380
  observer(pact);
5367
5381
  }
5368
5382
  }
5369
- } /**
5370
- * Task Provider
5371
- */
5383
+ }
5372
5384
  var _Pact = /*#__PURE__*/function () {
5373
5385
  function _Pact() {}
5374
5386
  _Pact.prototype.then = function (onFulfilled, onRejected) {
@@ -5437,17 +5449,6 @@ function _forTo(array, body, check) {
5437
5449
  _cycle();
5438
5450
  return pact;
5439
5451
  }
5440
- function _catch$5(body, recover) {
5441
- try {
5442
- var result = body();
5443
- } catch (e) {
5444
- return recover(e);
5445
- }
5446
- if (result && result.then) {
5447
- return result.then(void 0, recover);
5448
- }
5449
- return result;
5450
- }
5451
5452
  var TaskContext = React.createContext({});
5452
5453
  var TaskContextProvider = function TaskContextProvider(props) {
5453
5454
  var removeTask = function removeTask(task) {
@@ -5508,34 +5509,41 @@ var TaskContextProvider = function TaskContextProvider(props) {
5508
5509
  return Promise.reject(e);
5509
5510
  }
5510
5511
  };
5512
+ var executeListeners = function executeListeners() {
5513
+ try {
5514
+ var taskIDs = Object.keys(listeners);
5515
+ var _temp = _forTo(taskIDs, function (i) {
5516
+ var taskID = taskIDs[i];
5517
+ return Promise.resolve(task(taskID)).then(function (tsk) {
5518
+ var listener = listeners[taskID];
5519
+ if (listener) listener(tsk, appContextRef.current);
5520
+ });
5521
+ });
5522
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
5523
+ } catch (e) {
5524
+ return Promise.reject(e);
5525
+ }
5526
+ };
5511
5527
  var host = props.host,
5512
5528
  _props$url = props.url,
5513
5529
  url = _props$url === void 0 ? "/tasks" : _props$url,
5514
5530
  _props$frequency = props.frequency,
5515
5531
  frequency = _props$frequency === void 0 ? 1000 : _props$frequency,
5516
- children = props.children,
5517
- ctx = props.ctx;
5532
+ children = props.children;
5518
5533
  var API = CollectionAPI$1(url, host, "");
5519
5534
  var _useState = useState({}),
5520
5535
  listeners = _useState[0],
5521
5536
  setListeners = _useState[1];
5522
- var appContext = useContext(ctx);
5537
+ var appContext = useContext(appContext);
5538
+ var appContextRef = useRef(appContext);
5539
+ useEffect(function () {
5540
+ appContextRef.current = appContext;
5541
+ }, [appContext]);
5523
5542
  useEffect(function () {
5524
5543
  if (Object.keys(listeners).length === 0) return;
5525
5544
  var _interval = setInterval(function () {
5526
- try {
5527
- var taskIDs = Object.keys(listeners);
5528
- var _temp = _forTo(taskIDs, function (i) {
5529
- var taskID = taskIDs[i];
5530
- return Promise.resolve(task(taskID)).then(function (tsk) {
5531
- var listener = listeners[taskID];
5532
- if (listener) listener(tsk, appContext);
5533
- });
5534
- });
5535
- return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
5536
- } catch (e) {
5537
- return Promise.reject(e);
5538
- }
5545
+ executeListeners();
5546
+ return Promise.resolve();
5539
5547
  }, frequency);
5540
5548
  return function () {
5541
5549
  return clearInterval(_interval);