{"version":3,"names":["TickingActiveExpression","setExpressionOptionsForConventionStrategies","func","options","rest","Object","assign","checkImmediately","aexpr","args","check","iterable","TICKING_INSTANCES","forEach","checkAndNotify","clearDefaultActiveExpressions","clear","BaseActiveExpression","Set","constructor","add","new","target","addToRegistry","revoke","removeListeners","dispose","delete","disable2","disable","enable2","enable","setExpression","params"],"sources":["active-expression-ticking.js"],"sourcesContent":["import { BaseActiveExpression } from 'active-expression';\n\nconst TICKING_INSTANCES = new Set();\n\nexport function setExpressionOptionsForConventionStrategies(func, options = {}, ...rest) {\n  return [func, Object.assign({\n    checkImmediately: false\n  }, options), ...rest];\n}\n\nexport class TickingActiveExpression extends BaseActiveExpression {\n\n    // each implementation strategy ensures to track changes of the given expression\n    // in the case of ticking, we add the aexpr to a collection of tracked aexpr\n    // which enables them to recognize changes (here, explicitly through the `check` method)\n    constructor(func, ...args) {\n        super(func, ...args);\n        TICKING_INSTANCES.add(this);\n\n        if(new.target === TickingActiveExpression) {\n            this.addToRegistry();\n        }\n    }\n\n    // TODO: refactor/extractMethod with InterpreterActiveExpression\n    revoke() {\n        this.removeListeners();\n    }\n\n    dispose() {\n      TICKING_INSTANCES.delete(this);\n      super.dispose();\n    }\n  \n    disable2(...args) {\n      return super.disable(...args)\n    }\n\n    enable2(...args) {\n      return super.enable(...args)\n    }\n  \n    disable(...args) {\n      super.disable(...args)\n      return this;\n    }\n\n    enable(...args) {\n      super.enable(...args)\n      return this;\n    }\n  \n  /** the parameter `checkImmediately` is by default false for convention strategies */\n  setExpression(...params) {\n    return super.setExpression(...setExpressionOptionsForConventionStrategies(...params))\n  }\n}\n\nexport function aexpr(func, ...args) { return new TickingActiveExpression(func, ...args); }\n\n// TODO: the concrete semantic of enabled and disabled aexprs are not clear yet.\n// Instead, they are related to this concrete implementation.\n// For example, what happens if a disabled aexpr is re-enabled AND the value of the aexpr\n// has already changed? Should the callback be invoked with the new value and the lastValue\n// before the disabling? or with the actual last value? Or should it not be invoked until\n// something changes? If so, what is the last value? Or should aexprs simply not be able to be\n// re-enabled again? Or should they not even be disable-able; then, it would be the duty of\n// the callback/a built-upon concept to implement thiese functionalities appropriately\nexport function check(iterable = TICKING_INSTANCES) {\n    iterable.forEach(aexpr => aexpr.checkAndNotify());\n}\n\n// Remove all active expressions of this type from the system\n// afterward active expressions are only reachable by providing them explicitly in an iterable to `check`\n// Caution: Do not use this function unless you know what you are doing!\nexport function clearDefaultActiveExpressions() {\n    TICKING_INSTANCES.clear();\n}\n"],"mappings":";;;4BAUaA,uBAAuB;EAN7B,SAASC,2CAA2C,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE,GAAGC,IAAI,EAAE;IACvF,OAAO,CAACF,IAAI,EAAEG,MAAM,CAACC,MAAM,CAAC;MAC1BC,gBAAgB,EAAE;IACpB,CAAC,EAAEJ,OAAO,CAAC,EAAE,GAAGC,IAAI,CAAC;EACvB;EAkDO,SAASI,KAAK,CAACN,IAAI,EAAE,GAAGO,IAAI,EAAE;IAAE,OAAO,IAAIT,uBAAuB,CAACE,IAAI,EAAE,GAAGO,IAAI,CAAC;EAAE;;EAE1F;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,SAASC,KAAK,CAACC,QAAQ,GAAGC,iBAAiB,EAAE;IAChDD,QAAQ,CAACE,OAAO,CAACL,KAAK,IAAIA,KAAK,CAACM,cAAc,EAAE,CAAC;EACrD;;EAEA;EACA;EACA;EACO,SAASC,6BAA6B,GAAG;IAC5CH,iBAAiB,CAACI,KAAK,EAAE;EAC7B;EAAC;IAAA,6CAzEef,2CAA2C;IAAA;IAAA,OAsD3CO,KAAK;IAAA,OAULE,KAAK;IAAA,+BAOLK;EAA6B;EAAA;IAAA;MA3EpCE,oBAAoB,qBAApBA,oBAAoB;IAAA;IAAA;MAAA;MAAA;MAAA;QAAA;UAAA;QAAA;QAAA;UAAA,yCA2EbF,8DAA6B;UAAA;QAAA;QAAA;QAAA;MAAA;MAAA;QAAA;UAAA;QAAA;QAAA;UAA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