MCPcopy Create free account
hub / github.com/WebReflection/neverland / createEffect

Function createEffect

index.js:439–489  ·  view source on GitHub ↗
(asy)

Source from the content-addressed store, hash-verified

437 var stop = function stop() {};
438
439 var createEffect = function createEffect(asy) {
440 return function (effect, guards) {
441 var i = state.i++;
442 var _state3 = state,
443 hook = _state3.hook,
444 after = _state3.after,
445 stack = _state3.stack,
446 length = _state3.length;
447
448 if (i < length) {
449 var info = stack[i];
450 var _update = info.update,
451 values = info.values,
452 _stop = info.stop;
453
454 if (!guards || guards.some(different, values)) {
455 info.values = guards;
456 if (asy) _stop(asy);
457 var clean = info.clean;
458
459 if (clean) {
460 info.clean = null;
461 clean();
462 }
463
464 var _invoke = function _invoke() {
465 info.clean = effect();
466 };
467
468 if (asy) _update(_invoke);else after.push(_invoke);
469 }
470 } else {
471 var _update2 = asy ? reraf() : stop;
472
473 var _info = {
474 clean: null,
475 update: _update2,
476 values: guards,
477 stop: stop
478 };
479 state.length = stack.push(_info);
480 (fx.get(hook) || fx.set(hook, [])).push(_info);
481
482 var _invoke2 = function _invoke2() {
483 _info.clean = effect();
484 };
485
486 if (asy) _info.stop = _update2(_invoke2);else after.push(_invoke2);
487 }
488 };
489 };
490
491 var dropEffect = function dropEffect(hook) {
492 (effects.get(hook) || []).forEach(function (info) {

Callers 1

index.jsFile · 0.70

Calls 1

rerafFunction · 0.70

Tested by

no test coverage detected