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
(function() { | |
Dispather.register(function(action) { | |
if (action.type !== 'navigate') { | |
return; | |
} | |
window.history.pushState({}, '', action.path); | |
}); | |
})(); |
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
TaskStore = (function() { | |
var TaskStore = {}; | |
var state = {}; | |
TaskStore.addChangeListener = function() { | |
// left as an exercise - hint: event emitters | |
}; | |
TaskStore.addChangeListener = function() { |
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
AppLink = React.createClass({ | |
render: function() { | |
return ( | |
<a href={this.props.href} onClick={this.onClick}> | |
{this.props.children} | |
</a> | |
); | |
}, | |
onClick: function(event) { | |
// don't reload page - dispatch a navigate Action, instead |
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
TasksApp = React.createClass({ | |
getInitialState: function() { | |
return { | |
selectedTask: TaskStore.selectedTask(), | |
tasks: TaskStore.tasks(), | |
}; | |
}, | |
componentWillMount: function() { | |
TaskStore.addChangeListener(this.updateState); | |
}, |
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
class ExcludeXhr | |
def matches?(request) | |
!request.xhr? | |
end | |
end | |
Rails.application.routes.draw do | |
constraints(ExcludeXhr.new) do | |
root 'home#index' # home/index just renders our single page client-side app | |
get '*path', to: "home#index", via: :all |
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
// Router exposes two methods: | |
// | |
// - register binds regex patterns to callbacks, | |
// | |
// - route takes a path, and executes the callback associated | |
// with the first regex that matches that path | |
Router = function() { | |
var instance = {}; |
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
TaskStore = (function() { | |
var TaskStore = {}; | |
var state = {}; | |
TaskStore.addChangeListener = function() { | |
// left as an exercise - hint: event emitters | |
}; | |
TaskStore.addChangeListener = function() { |
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
TasksApp = React.createClass({ | |
// all component state originates from TaskStore, upstream | |
getInitialState: function() { | |
return { | |
selectedTask: TaskStore.selectedTask(), | |
tasks: TaskStore.tasks(), | |
}; | |
}, | |
// and when the TaskStore's state changes, we update this component's |
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
.git* | |
log* |
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
default: &default | |
adapter: postgresql | |
pool: 5 | |
host: db | |
username: postgres | |
timeout: 5000 | |
development: | |
<<: *default | |
database: expense_tracker_dev |