Skip to content

Instantly share code, notes, and snippets.

View clalimarmo's full-sized avatar

Carlos Lalimarmo clalimarmo

View GitHub Profile
@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 / 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 / tasks_app.jsx
Last active September 21, 2015 15:23
Deep Linking with React + Flux, main controller view, replace links with AppLink component
TasksApp = React.createClass({
getInitialState: function() {
return {
selectedTask: TaskStore.selectedTask(),
tasks: TaskStore.tasks(),
};
},
componentWillMount: function() {
TaskStore.addChangeListener(this.updateState);
},
@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 / 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 / app_link.jsx
Last active September 16, 2015 01:29
Deep Linking with React + Flux, AppLink component
@clalimarmo
clalimarmo / router.js
Last active September 15, 2015 18:53
Deep Linking with React + Flux, example Router, to be used by a Store
// 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 = {};
@clalimarmo
clalimarmo / task_store.js
Created September 15, 2015 16:54
Deep Linking with React + Flux, Task Store, step 1
TaskStore = (function() {
var TaskStore = {};
var state = {};
TaskStore.addChangeListener = function() {
// left as an exercise - hint: event emitters
};
TaskStore.addChangeListener = function() {
@clalimarmo
clalimarmo / Dockerfile
Last active September 9, 2015 15:17
Rails development environment with Docker, Dockerfile
FROM ruby:2.2.3
RUN \
apt-get update -qq && \
apt-get install -y build-essential
RUN mkdir app
WORKDIR app
COPY Gemfile ./
RUN bundle install
@clalimarmo
clalimarmo / .dockerignore
Last active September 9, 2015 14:32
Rails development environment with Docker, minimal .dockerignore
.git*
log*