Skip to content

Commit 47c1c2b

Browse files
committed
document event and observer silence, isSilenced, and resume
1 parent a4709ca commit 47c1c2b

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

docs/edge/ractive.observe().md.hbs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ ractive.observe( 'foo bar baz', function ( newValue, oldValue, keypath ) {
2222

2323
See {{{createLink 'Observers'}}} for more detail.
2424

25+
> ### ractive.observe - all versions
26+
> Returns an `Object` with:
27+
> * `cancel` method, which removes all observers subscribed by the `observe` call
28+
> * `silence` method, which prevents the handlers from firing until they are resumed
29+
> * `isSilenced` method, which returns true if the listener is currently silenced
30+
> * `resume` method, which allows the handlers to fire until they are again silenced
2531

2632
> ### ractive.observe( keypath, callback[, options ])
27-
> Returns an object with a `cancel` method, for cancelling the observer
28-
2933
> > #### **keypath** *`String`*
3034
> > The [keypath](keypaths) to observe, or a group of space-separated keypaths. Any of the keys can be a `*` character, which is treated as a wildcard.
3135
> > #### **callback** *`Function`*
@@ -40,9 +44,7 @@ See {{{createLink 'Observers'}}} for more detail.
4044

4145

4246
> ### ractive.observe( map[, options ])
43-
> Returns an object with a `cancel` method, for cancelling all observers
44-
4547
> > #### **map** *`Object`*
4648
> > A map of `keypath: observer` pairs
4749
> > #### options *`Object`*
48-
> > As above.
50+
> > As above.

docs/edge/ractive.on().md.hbs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ title: ractive.on()
33
---
44
Subscribe to {{{createLink 'events overview' 'events'}}}.
55

6+
> ### ractive.on - all versions
7+
> Returns an `Object` with:
8+
> * `cancel` method, which removes all listeners subscribed by the `on` call
9+
> * `silence` method, which prevents the handlers from firing until they are resumed
10+
> * `isSilenced` method, which returns true if the listener is currently silenced
11+
> * `resume` method, which allows the handlers to fire until they are again silenced
12+
613
> ### ractive.on( eventName, handler )
7-
> Returns an `Object` with a `cancel` method, which removes the handler.
814
> > #### **eventName** *`String`*
915
> > The name of the event to subscribe to
1016
> > #### **handler** *`Function`*
1117
> > The function that will be called, with `ractive` as `this`. The arguments depend on the event. Returning `false` from the handler will stop propagation and prevent default of DOM events and cancel {{{createLink 'event bubbling'}}}.
1218

1319
> ### ractive.on( obj )
14-
> Returns an `Object` with a `cancel` method, which removes all handlers in the passed-in `obj`.
1520
> > #### **obj** *`Object`*
1621
> > An object with keys named for each event to subscribe to. The value at each key is the handler function for that event.
1722

@@ -40,5 +45,3 @@ ractive.on({
4045
'select foo.* bar': function () {...}
4146
});
4247
```
43-
44-

0 commit comments

Comments
 (0)