- bla
- blabla
- bar
gem install blablabla
TasksApp = React.createClass({ | |
getInitialState: function() { | |
return { | |
selectedTask: TaskStore.selectedTask(), | |
tasks: TaskStore.tasks(), | |
}; | |
}, | |
componentWillMount: function() { | |
TaskStore.addChangeListener(this.updateState); | |
}, |
TaskStore = (function() { | |
var TaskStore = {}; | |
var state = {}; | |
TaskStore.addChangeListener = function() { | |
// left as an exercise - hint: event emitters | |
}; | |
TaskStore.addChangeListener = function() { |
(function() { | |
Dispather.register(function(action) { | |
if (action.type !== 'navigate') { | |
return; | |
} | |
// sometimes we don't want to create history entries (see below) | |
if (action.pushState) { | |
window.history.pushState( | |
{path: action.path}, | |
'', |
// example app initialization | |
$(function() { | |
Dispatcher.dispatch({ | |
type: 'initialize app', | |
path: window.location.pathname, | |
}); | |
}); |
// tired of this extension pattern | |
var Cow = AnimalFactory({ | |
getVoice: function() { return 'moo'; }), | |
numLegs: 4, | |
name: 'Cow', | |
}) | |
// propose this one instead | |
var MutantCow = AnimalFactory.extend() | |
.getVoice(function() { return 'moo'; }) |
const BookStore = function(deps) { | |
const self = Coherence(deps); | |
self.handleAction('search-book', searchBook); | |
return self.fluxSafe(); | |
function searchBook(payload) { | |
deps.books.fetch(payload.id).then(function(response) { | |
self.setData('book', response); | |
}) | |
} |
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 |
var appliedFilters = {}; | |
function anyFilterApplied() { | |
return Object.keys(appliedFilters).length > 0; | |
} | |
function applyFilter(filter, key) { | |
appliedFilters[key] = filter; | |
} |
const Cache = function(deps) { | |
const self = {}; | |
const requested = {}; | |
self.fetch = function(href) { | |
requested[href] = requested[href] || new Promise((resolve, reject) => { | |
const collection = deps.Collection(); | |
collection.fetch(href).done(() => { | |
resolve(collection); | |
}); |