Skip to content

Commit 70d67fc

Browse files
author
Vlad Balin
committed
Docs cleanup
1 parent 94087c9 commit 70d67fc

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

docsource/04_Record/03_Updates_and_change_events.md

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Works similar to `record.set( otherRecord.attributes, { merge : true });
3535

3636
## Listening to events
3737

38-
### Deep changes detection
38+
### Deep changes observation
3939

4040
Records automatically listens to change events of nested records and collections, and triggers the corresponding change events on its attributes. It means that the single attribute change deeply inside of aggregation tree will trigger change events on all the parents in a sequence.
4141

@@ -68,41 +68,12 @@ _Watcher function_ has the signature `( attrValue, attrName ) => void` and is ex
6868
}
6969
```
7070

71-
### Generic event API
71+
### Custom events subscribtion.
7272

73-
Generic events API can be used to listen to any record's events.
73+
`listener.listenTo()` and `listener.listenToOnce()` methods can be used to listen to the any of the change events.
7474

75-
#### listener.listenTo( record, eventName, handler )
76-
#### listener.listenTo( record, { eventName : handler, ... } )
77-
78-
Subscribe for `eventName` from the record. Subscription will be automatically cancelled when messenger is disposed.
79-
The handler is executed in the context of the listener.
80-
81-
#### listener.stopListening( record?, eventName?, hander? )
82-
#### listener.stopListening( record?, { eventName : handler, ... } )
83-
84-
`listener.stopListening( record )` stops subscriptions from the record.
85-
86-
`listener.stopListening()` stops _all_ event subscriptions and _is called automatically_ from the `listener.dispose()`.
87-
88-
### Low-level event API
89-
90-
Low level event API is more efficient but requires precise `off()` call to stop the subscription. It must be done
91-
in overidden `dispose()` method to prevent memory leaks.
92-
93-
#### record.onChanges( handler, context? )
94-
95-
Subscribe for `change` event from the record. If `context` is passed, handler will be called in this context.
96-
97-
#### record.on( eventName, handler, context? )
98-
#### record.on( { eventName : handler, ... }, context? )
99-
100-
Subscribe for the `eventName` from the record. If `context` is passed, handler will be called in this context.
101-
102-
#### record.off( eventName, handler, context? )
103-
#### record.off( { eventName : handler, ... }, context? )
104-
105-
Cancel event subscription.
75+
If listener itself is the record or collection, subscribtions will be stopped automatically. Otherwise they must be stopped
76+
manually with `listener.stopListening()` call to prevent memory leaks.
10677

10778
## Transactions
10879

0 commit comments

Comments
 (0)