0.3.2 • Published 22 days ago

object-subscriptions v0.3.2

Weekly downloads
-
License
-
Repository
github
Last release
22 days ago

object-subscriptions

Nested object with mutations and subscribers

Examples

Calculate and Subscribe

import {NestedObjectWithSubscriptions} from "object-subscriptions";

const obj = new NestedObjectWithSubscriptions();

obj.set("aa.bb", 123);
obj.set("cc.dd", 123);

obj.calculate(["aa.bb", "cc.dd"], (a, b) => {
    return a + b;
}, "ee.ff")

obj.subscribe("ee.ff", (value) => {
    console.log("VAL!", value);
});

Custom Separator and Traversal

import {NestedObjectWithSubscriptions} from "object-subscriptions";

const obj = new NestedObjectWithSubscriptions({}, {separator: '/'});

obj.set("aa/bb", 123);
obj.set("cc/dd", 123);

obj.calculate(["aa/bb", "cc/dd"], (a, b) => {
    return a + b;
}, "ee/ff")

obj.subscribe("ee/ff", (value) => {
    console.log("VAL!", value);
});


for(let [pathParts, value] of obj.entries({pathParts: true})) {
    console.log(pathParts, value);
}

Take a slice

import {NestedObjectWithSubscriptions} from "object-subscriptions";

const obj = new NestedObjectWithSubscriptions({}, {separator: '/'});

obj.set("aa/bb", 123);

const child = obj.child("aa");

console.log("VAL!", child.get([]));
0.3.2

22 days ago

0.3.1

2 months ago

0.3.0

2 months ago

0.2.3

2 months ago

0.2.2

2 months ago

0.2.1

2 months ago

0.2.0

2 months ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.3

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.1

2 years ago