-
Notifications
You must be signed in to change notification settings - Fork 2
Recursive events
Tyler Long edited this page Oct 11, 2018
·
1 revision
obj.$ tracks all the events inside obj, be them its own events or its children's events.
Children could be direct children or indirect children (children's children).
const rectangle = SubX.create({ position: { }, size: { } })
rectangle.$.subscribe(console.log)
rectangle.position.x = 0
rectangle.position.y = 0
rectangle.size.width = 200
rectangle.size.height = 100{ type: 'SET',
val: 0,
oldVal: undefined,
path: [ 'position', 'x' ] }
{ type: 'SET',
val: 0,
oldVal: undefined,
path: [ 'position', 'y' ] }
{ type: 'SET',
val: 200,
oldVal: undefined,
path: [ 'size', 'width' ] }
{ type: 'SET',
val: 100,
oldVal: undefined,
path: [ 'size', 'height' ] }
Since nested objects are also SubX objects, they support $ too.
For example you can rectangle.size.$.subscribe(...) to track rectangle.size and its children's events.