Skip to content

Instantly share code, notes, and snippets.

View clalimarmo's full-sized avatar

Carlos Lalimarmo clalimarmo

View GitHub Profile
@clalimarmo
clalimarmo / app_link.jsx
Last active September 16, 2015 01:29
Deep Linking with React + Flux, AppLink component
@clalimarmo
clalimarmo / task_store.js
Last active September 21, 2015 15:25
Deep Linking with React + Flux, Task Store, modified to route on "navigate" Actions
TaskStore = (function() {
var TaskStore = {};
var state = {};
TaskStore.addChangeListener = function() {
// left as an exercise - hint: event emitters
};
TaskStore.addChangeListener = function() {
@clalimarmo
clalimarmo / url_store.js
Last active September 21, 2015 15:09
Deep Linking with React + Flux, URL Store, for maintaining correct URL state
(function() {
Dispather.register(function(action) {
if (action.type !== 'navigate') {
return;
}
window.history.pushState({}, '', action.path);
});
})();
@clalimarmo
clalimarmo / url_store.js
Last active September 21, 2015 15:36
Deep Linking with React + Flux, URL Store, with support for browser "back"
(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},
'',
@clalimarmo
clalimarmo / app_link.jsx
Last active September 21, 2015 15:20
Deep Linking with React + Flux, AppLink component, updated to support browser "back"
@clalimarmo
clalimarmo / app_init.js
Created September 15, 2015 18:52
Deep Linking with React + Flux, dispatching an action for app initialization on page load
// example app initialization
$(function() {
Dispatcher.dispatch({
type: 'initialize app',
path: window.location.pathname,
});
});
@clalimarmo
clalimarmo / extension-patterns.js
Last active October 2, 2015 18:25
How things are done everywhere. Versus how I want them to be done.
// 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'; })

Setup

  • bla
  • blabla
  • bar

gem install blablabla

Run tests

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);
})
}
@clalimarmo
clalimarmo / filters.js
Last active October 21, 2015 20:22 — forked from gbau/filters.js
var appliedFilters = {};
function anyFilterApplied() {
return Object.keys(appliedFilters).length > 0;
}
function applyFilter(filter, key) {
appliedFilters[key] = filter;
}