obs.mjs implements observables via proxies. This is a stripped-down version of https://github.com/mitranim/espo. The core API is identical. Check the readme in the linked repo.
Short overview of features:
- Any object can be made observable. Subclassing is available but not required.
- Sub/resub can be made invisible and completely automatic, just by accessing properties.
- Trigger can be completely invisible and automatic, by property modification.
- Arbitrary properties can be observed. No need for special annotations.
- Non-enumerable properties are exempt. This provides an opt-out.
- Implicit resource cleanup: automatically calls
.deinit()
on removed/replaced objects. - Your objects are squeaky clean, with no added library junk other than mandatory
.deinit()
. - Nice-to-use in plain JS. Doesn't rely on decorators, TS features, etc.
- Easy to wire into any UI system.
- Tiny with no external dependencies.
Until the docs are fully migrated, see https://github.com/mitranim/espo. The core API is identical.
The following APIs are exported but undocumented. Check obs.mjs.
function deinit
function isDe
function reqDe
function isObs
function reqObs
function isTrig
function reqTrig
function isSub
function reqSub
function isSubber
function reqSubber
function isRunTrig
function reqRunTrig
function ph
function self
const keyPh
const keySelf
function de
function obs
function deObs
class StaticProxied
class Proxied
class De
class Obs
class DeObs
const dyn
class Sched
class ImpObs
class Rec
class Moebius
class Loop
class Ph
class DeinitPh
class ObsPh
class DeObsPh
function deinitAll