Skip to content

Commit 6beea89

Browse files
committed
Merge branch 'jordan/refactor-everything!' of https://github.com/optimizely/nuclear-js into yun/grouping-observers-by-getters
2 parents fe88c19 + ba88051 commit 6beea89

File tree

1 file changed

+35
-15
lines changed

1 file changed

+35
-15
lines changed

docs/src/docs/07-api.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,6 @@ Dispatches a message to all registered Stores. This process is done synchronousl
2929
reactor.dispatch('addUser', { name: 'jordan' })
3030
```
3131

32-
#### `Reactor#batch(fn)`
33-
34-
_added in 1.1_
35-
36-
Allows multiple dispatches within the `fn` function before notifying any observers.
37-
38-
```javascript
39-
reactor.batch(function() {
40-
reactor.dispatch('addUser', { name: 'jordan' })
41-
reactor.dispatch('addUser', { name: 'james' })
42-
})
43-
44-
// does a single notify to all observers
45-
```
46-
4732
#### `Reactor#evaluate(Getter | KeyPath)`
4833

4934
Returns the immutable value for some KeyPath or Getter in the reactor state. Returns `undefined` if a keyPath doesn't have a value.
@@ -85,6 +70,41 @@ reactor.observe([
8570
])
8671
```
8772
73+
#### `Reactor#batch(fn)`
74+
75+
_added in 1.1_
76+
77+
Allows multiple dispatches within the `fn` function before notifying any observers.
78+
79+
```javascript
80+
reactor.batch(function() {
81+
reactor.dispatch('addUser', { name: 'jordan' })
82+
reactor.dispatch('addUser', { name: 'james' })
83+
})
84+
85+
// does a single notify to all observers
86+
```
87+
88+
#### `Reactor#batchStart()`
89+
90+
_added in 1.2_
91+
92+
Sets the reactor in batch mode, where dispatches don't cause observer notification until `batchEnd()` is called.
93+
94+
```javascript
95+
// the following is equivalent to the `reactor.batch` example
96+
reactor.batchStart()
97+
reactor.dispatch('addUser', { name: 'jordan' })
98+
reactor.dispatch('addUser', { name: 'james' })
99+
reactor.batchEnd()
100+
```
101+
102+
#### `Reactor#batchEnd()`
103+
104+
_added in 1.2_
105+
106+
Signifies the end of reactor batching and will notify all observers of the changes that happened since `batchStart`
107+
88108
#### `Reactor#serialize()`
89109
90110
_added in 1.1_

0 commit comments

Comments
 (0)