-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up basic Flux with Stores and Actions
- Loading branch information
Showing
6 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Actions = require('flummox').Actions | ||
|
||
class PostActions extends Actions | ||
|
||
module.exports = PostActions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters