deep-state-observer
Advanced tools
Comparing version 1.0.9 to 1.0.10
{ | ||
"name": "deep-state-observer", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "Deep state observer is an state management library that will fire listeners only when specified object node (which also can be a wildcard) was changed.", | ||
@@ -5,0 +5,0 @@ "main": "index.cjs.js", |
@@ -318,2 +318,38 @@ const { Store, wildcardToRegex } = require('../index.cjs.js'); | ||
}); | ||
it('should watch recursively within object with numeric values', () => { | ||
const state = new Store({ | ||
one: { | ||
two: { | ||
1: { x: 1 }, | ||
2: { x: 2 }, | ||
3: { x: 3 } | ||
} | ||
} | ||
}); | ||
const paths = []; | ||
const values = []; | ||
state.subscribeAll(['one.two...'], (value, path) => { | ||
paths.push(path); | ||
values.push(value); | ||
}); | ||
expect(paths.length).toEqual(1); | ||
expect(values.length).toEqual(1); | ||
expect(paths[0]).toEqual('one.two'); | ||
expect(values[0]).toEqual({ | ||
1: { x: 1 }, | ||
'2': { x: 2 }, | ||
3: { x: 3 } | ||
}); | ||
state.update('one.two.2.x', 22); | ||
expect(paths.length).toEqual(2); | ||
expect(values.length).toEqual(2); | ||
expect(paths[1]).toEqual('one.two.2.x'); | ||
expect(values[1]).toEqual({ | ||
1: { x: 1 }, | ||
'2': { x: 22 }, | ||
3: { x: 3 } | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
167116
4892