Skip to content

Commit cbf5c8a

Browse files
author
Pavlo Aksonov
committed
Merge pull request #38 from danscan/patch-1
Use javascript syntax highlighting in examples
2 parents d0167fb + d0b6cad commit cbf5c8a

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ React Native Router using Flux architecture
1616
![demo-2](https://cloud.githubusercontent.com/assets/1321329/9466261/de64558e-4b33-11e5-8ada-0fcd49442769.gif)
1717

1818

19-
```
19+
```javascript
2020
'use strict';
2121

2222
var React = require('react-native');
@@ -69,7 +69,7 @@ AppRegistry.registerComponent('Example', () => Example);
6969
```
7070

7171
components/Launch.js (initial screen)
72-
```
72+
```javascript
7373
'use strict';
7474

7575
var React = require('react-native');
@@ -114,26 +114,28 @@ module.exports = Launch;
114114
* Actions.ACTION_NAME(PARAMS) will call appropriate action and params will be passed to next screen.
115115
4. In your Flux stores (optional). You may subscribe to any push/replace/pop 'page' actions in your store.
116116
It could be necessary if you want to process user data somehow. For example, if some component manages user form and have "Save" button which should store that data and pop the screen, you may use Actions.pop(this.state) in that component and then subscribe to Actions.pop actions within store:
117-
118-
class SearchFilterStore {
119-
constructor(){
120-
this.bindAction(Actions.pop, this.onSet);
121-
}
122-
123-
onSet(data){
124-
this.waitFor(PageStore.dispatchToken);
125-
var route = PageStore.getState().currentRoute;
126-
127-
if (route == 'yourFORM'){
128-
// save data
129-
130-
this.saveData(data);
131-
return true;
132-
}
133-
return false;
117+
118+
```javascript
119+
class SearchFilterStore {
120+
constructor(){
121+
this.bindAction(Actions.pop, this.onSet);
122+
}
123+
124+
onSet(data){
125+
this.waitFor(PageStore.dispatchToken);
126+
var route = PageStore.getState().currentRoute;
127+
128+
if (route == 'yourFORM'){
129+
// save data
130+
131+
this.saveData(data);
132+
return true;
134133
}
134+
return false;
135135
}
136-
module.exports = alt.createStore(SearchFilterStore, 'SearchFilterStore');
136+
}
137+
module.exports = alt.createStore(SearchFilterStore, 'SearchFilterStore');
138+
```
137139

138140

139-
Here PageStore.getState().currentRoute is used to check current page, so the store will process only data for needed route.
141+
Here PageStore.getState().currentRoute is used to check current page, so the store will process only data for needed route.

0 commit comments

Comments
 (0)