File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1
1
var React = require ( 'react' ) ;
2
+ var Reflux = require ( 'reflux' ) ;
3
+ var ImageStore = require ( '../stores/image-store' ) ;
2
4
3
5
module . exports = React . createClass ( {
6
+ mixins : [
7
+ Reflux . listenTo ( ImageStore , 'onChange' )
8
+ ] ,
4
9
render : function ( ) {
5
10
return < div >
6
11
I am an image detail.
7
12
</ div >
13
+ } ,
14
+ onChange : function ( event , image ) {
15
+ this . setState ( {
16
+ image : image
17
+ } ) ;
8
18
}
9
19
} ) ;
Original file line number Diff line number Diff line change @@ -15,6 +15,16 @@ module.exports = Reflux.createStore({
15
15
this . triggerChange ( ) ;
16
16
} . bind ( this ) ) ;
17
17
} ,
18
+ find : function ( id ) {
19
+ var image = _ . findWhere ( this . images , { id : id } ) ;
20
+
21
+ if ( image ) {
22
+ return image
23
+ } else {
24
+ this . getImage ( id ) ;
25
+ return null
26
+ }
27
+ } ,
18
28
triggerChange : function ( ) {
19
29
this . trigger ( 'change' , this . images ) ;
20
30
}
You can’t perform that action at this time.
0 commit comments