Skip to content

Commit 25938e3

Browse files
committed
Added more information about the library usage
1 parent db92f30 commit 25938e3

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

README.md

+21-12
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,21 @@ It will also download lodash as a dependency.
3030

3131
## Usage
3232

33-
Create an action by calling `createAction`.
33+
For a full example check the [`test/index.js`](test/index.js) file.
3434

35-
```javascript
36-
var Reflux = require('reflux');
35+
### Creating actions
36+
37+
Create an action by calling `Reflux.createAction`.
3738

39+
```javascript
3840
var statusUpdate = Reflux.createAction();
3941
```
4042

41-
Create a data store by passing a definition object to `createStore`.
43+
It is as simple as that.
44+
45+
### Creating data stores
46+
47+
Create a data store much like ReactJS's own `React.createClass` by passing a definition object to `Reflux.createStore`. You may set up all action listeners in the `init` function and register them by calling the store's own `listenTo` function.
4248

4349
```javascript
4450
// Creates a DataStore
@@ -60,7 +66,11 @@ var statusStore = Reflux.createStore({
6066
});
6167
```
6268

63-
In your component, register to listen to your data store like this:
69+
In the above example, whenever the action is called, the store's `output` callback will be called with whatever parameters was sent in the action. E.g. if the action is called as `statusUpdate(true)` then the flag argument in `output` function is `true`.
70+
71+
### Listening to changes in data store
72+
73+
In your component, register to listen to changes in your data store like this:
6474

6575
```javascript
6676
// Fairly simple view component that outputs to console
@@ -80,15 +90,14 @@ Invoke actions as if they were functions:
8090
```javascript
8191
statusUpdate(true);
8292
statusUpdate(false);
83-
84-
/**
85-
* Will output:
86-
* status: ONLINE
87-
* status: OFFLINE
88-
*/
8993
```
9094

91-
See `test/index.js` for more example on how to use the package.
95+
With the setup above this will output the following in the console:
96+
97+
```
98+
status: ONLINE
99+
status: OFFLINE
100+
```
92101

93102
## License
94103

0 commit comments

Comments
 (0)