getDependencyDataOf
Get the dependencies of an observable.
.getDependencyDataOf(observable, [key])
Get the dependencies of an observable, if key
is provided, it would returns the
dependencies of the key
on the observable.
const one = new SimpleObservable( "one" );
const me = new SimpleMap( { age: 30 } );
canReflectDeps.getDependencyDataOf( one );
// or pass a key for map-like observables
canReflectDeps.getDependencyDataOf( me, "age" );
The ouput is an object with either (or both) top level properties:
{
whatIChange, // Observables affected by the object passed as an argument,
whatChangesMe // Observables that affect the object passed as an argument
}
Each of these properties contain an object with the following shape:
{
mutate, // Mutation dependencies
derive // Observables from which the parent derives its value
}
Finally, mutate
and derive
contain dependency records which are objects with
either a valueDependecies
property (a Set of observables) or a keyDependencies
property (a Map where each key is an observable and the keys' value is a set of
keys or properties of the observable).
Parameters
- observable
{Object}
:The observable to get dependencies from.
- key
{String}
:The key on a map-like observable.