Skip to content

Commit 67742f1

Browse files
author
Vlad Balin
committed
New documentation structure
1 parent 3053f69 commit 67742f1

File tree

9 files changed

+1011
-1218
lines changed

9 files changed

+1011
-1218
lines changed

docs/chapters/Events.md

Lines changed: 45 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -23,51 +23,18 @@ class Messenger {
2323

2424
> `Messenger` abstract base class is included with Type-R, see below.
2525
26-
### eventsSource.trigger(event, arg1, arg2, ... )
26+
### trigger(event, arg1, arg2, ... )
2727

2828
Trigger callbacks for the given event, or space-delimited list of events. Subsequent arguments to trigger will be passed along to the event callbacks.
2929

30-
## Messenger
31-
32-
Messenger is an abstract base class implementing Events mixin and some convenience methods.
33-
As all Type-R classes, its definition must be preceded with the `@define` decorator.
34-
35-
```javascript
36-
import { define, Messenger } from 'type-r'
37-
38-
@define class MyMessenger extends Messenger {
39-
40-
}
41-
```
42-
43-
### `readonly` messenger.cid
44-
45-
Unique run-time only messenger instance id (string).
46-
47-
### messenger.initialize()
48-
49-
Callback which is called at the end of the constructor.
50-
51-
### messenger.dispose()
52-
53-
Executes `messenger.stopListening()` and `messenger.off()`.
54-
55-
Objects must be disposed to prevent memory leaks caused by subscribing for events from singletons.
56-
57-
## High-level listening API
58-
59-
All high-level event subscriptions are stopped automatically on the listener's disposal, and thus does not introduce memory leaks.
60-
61-
This is the preferable listening API and must be used in all application code.
62-
63-
### listener.listenTo(other, event, callback)
30+
### listenTo(source, event, callback)
6431
Tell an object to listen to a particular event on an other object. The advantage of using this form, instead of other.on(event, callback, object), is that listenTo allows the object to keep track of the events, and they can be removed all at once later on. The callback will always be called with object as context.
6532

6633
```javascript
6734
view.listenTo(record, 'change', view.render );
6835
```
6936

70-
### listener.stopListening([other], [event], [callback])
37+
### stopListening([source], [event], [callback])
7138

7239
Tell an object to stop listening to events. Either call stopListening with no arguments to have the object remove all of its registered callbacks ... or be more precise by telling it to remove just the events it's listening to on a specific object, or a specific event, or just a specific callback.
7340

@@ -79,15 +46,11 @@ Tell an object to stop listening to events. Either call stopListening with no ar
7946

8047
All Type-R classes execute `this.stopListening()` from their `dispose()` method.
8148

82-
### listener.listenToOnce(other, event, callback)
49+
### listenToOnce(source, event, callback)
8350

8451
Just like listenTo, but causes the bound callback to fire only once before being removed.
8552

86-
## Low-level listening API
87-
88-
This API is more efficient but requires manual action to stop the subscription. Must be used with care.
89-
90-
### eventSource.on(event, callback, [context])
53+
### on(event, callback, [context])
9154

9255
Bind a callback function to an object. The callback will be invoked whenever the event is fired. If you have a large number of different events on a page, the convention is to use colons to namespace them: `poll:start`, or `change:selection`. The event string may also be a space-delimited list of several events...
9356

@@ -115,7 +78,7 @@ All event methods also support an event map syntax, as an alternative to positio
11578

11679
To supply a context value for this when the callback is invoked, pass the optional last argument: `record.on('change', this.render, this)` or `record.on({change: this.render}, this)`.
11780

118-
### eventSource.off([event], [callback], [context])
81+
### off([event], [callback], [context])
11982

12083
Remove a previously bound callback function from an object. If no context is specified, all of the versions of the callback with different contexts will be removed. If no callback is specified, all callbacks for the event will be removed. If no event is specified, callbacks for all events will be removed.
12184

@@ -138,32 +101,60 @@ Remove a previously bound callback function from an object. If no context is spe
138101

139102
Note that calling `record.off()`, for example, will indeed remove all events on the record — including events that Backbone uses for internal bookkeeping.
140103

141-
### eventsSource.once(event, callback, [context])
104+
### once(event, callback, [context])
142105
Just like `on()`, but causes the bound callback to fire only once before being removed. Handy for saying "the next time that X happens, do this". When multiple events are passed in using the space separated syntax, the event will fire once for every event you passed in, not once for a combination of all events
143106

144-
## Record events
107+
## Messenger class
145108

146-
### `event` "change:attrName" (record, value, options)
109+
Messenger is an abstract base class implementing Events mixin and some convenience methods.
147110

148-
When a specific attribute has been updated
111+
```javascript
112+
import { define, Messenger } from 'type-r'
113+
114+
class MyMessenger extends Messenger {
115+
116+
}
117+
```
118+
119+
### `implements` Events
120+
121+
Messenger implements [Events](#events-mixin) mixin.
122+
123+
### cid
124+
125+
Unique run-time only messenger instance id (string).
126+
127+
### initialize()
128+
129+
Callback which is called at the end of the constructor.
130+
131+
### dispose()
132+
133+
Executes `messenger.stopListening()` and `messenger.off()`.
134+
135+
Objects must be disposed to prevent memory leaks caused by subscribing for events from singletons.
136+
137+
## Built-in events
149138

150139
### `event` "change" (record, options)
151140

152-
When a record's attributes have changed.
141+
When a record's attributes have changed. Triggered by both record and collection containing the record.
153142

154-
## Collection events
143+
### `event` "change:attrName" (record, value, options)
144+
145+
When a specific record's attribute has been updated
155146

156147
### `event` "changes" (collection, options)
157148

158-
The main change event. Single event triggered when the collection has been changed.
149+
When collection has changed. Single event triggered when the collection has been changed.
159150

160-
### `event` "update" (collection, options)
151+
### `event` "reset" (collection, options)
161152

162-
Single event triggered after any number of records have been added or removed from a collection.
153+
When the collection's entire contents have been reset (`reset()` method was called).
163154

164-
### `event` "reset" (collection, options)
155+
### `event` "update" (collection, options)
165156

166-
When the collection's entire contents have been reset.
157+
Single event triggered after any number of records have been added or removed from a collection.
167158

168159
### `event` "sort" (collection, options)
169160

@@ -177,6 +168,3 @@ When a record is added to a collection.
177168

178169
When a record is removed from a collection.
179170

180-
### `event` "change" (record, options)
181-
182-
When a record's attributes have changed.

docs/chapters/aggregation.md

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)