Permalink
Browse files

Set up basic Flux with Stores and Actions

  • Loading branch information...
nambrot committed Mar 22, 2015
1 parent 0e1e049 commit 715a1a4567775e7e818007ad017faf181194929f
@@ -0,0 +1,5 @@
Actions = require('flummox').Actions

class PostActions extends Actions

module.exports = PostActions
@@ -1,6 +1,10 @@
React = require('react')
Router = require('react-router')
routes = require('routes')
Flux = require('flux')
FluxComponent = require('flummox/component')

flux = new Flux()
Router.run routes, Router.HistoryLocation, (Handler, state) ->
React.render(<Handler />, document.getElementById("reactContent"))
handler = <FluxComponent flux={flux} render={ => <Handler />}></FluxComponent>
React.render(handler, document.getElementById("reactContent"))
@@ -0,0 +1,11 @@
Flummox = require('flummox').Flummox
PostsStore = require('stores/post')
PostActions = require('actions/post')

class AppFlux extends Flummox
constructor: ->
super()
@createActions 'posts', PostActions
@createStore 'posts', PostsStore, this

module.exports = AppFlux

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,15 @@
Store = require('flummox').Store
Immutable = require('immutable')

getDefaultState = ->
{ posts: Immutable.OrderedMap(), didFetchAll: false }

class PostsStore extends Store
constructor: (flux) ->
super()

postActionIds = flux.getActionIds('posts')
@state = getDefaultState()
@flux = flux

module.exports = PostsStore
@@ -17,6 +17,8 @@
},
"dependencies": {
"react": "*",
"react-router": "*"
"react-router": "*",
"immutable": "*",
"flummox": "*"
}
}

0 comments on commit 715a1a4

Please sign in to comment.