As a stand-in to a full-fledged, publicly accessible JSON API, it would be incredibly liberating to have a Handlebars helper which allows us to loop through posts by parameters (maybe query params could even be mixed into the Handlebars context) instead of some internal state dictated by the URL. This would allow for easy creation of "related content", or a "search" function.
This file contains hidden or 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
import BaseView from './BaseView'; | |
import listenToMany from '../utils/listenToMany'; | |
import template from '../templates/user'; | |
// Backbone's extend + ES6 | |
export default BaseView.extend({ | |
template, | |
listenToMany | |
}); |
When I render OfferList through React Router, The result is a rejected promise, saying:
`An error occured when handling the DONE state of a fetch`
{
message: "Not found",
name: "Not found",
status: 404
}
This file contains hidden or 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
import _ from 'underscore'; | |
/** | |
* Backbone utility, to listen to multiple Backbone Events, | |
* structured like the native 'events' hash. Shortcuts things like | |
* `collectionEvents` on CollectionView, and `triggers` on Views. | |
* @param {class instance} obj object to listen to. | |
* @param {object} eventHash hash of events (prop:event, prop on current object) and handlers (value) | |
* @param {class instance} context optional context to call handlers with. | |
* @return {null} Doesn't return. |
This file contains hidden or 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
import React, { Component } from 'react'; | |
class Parent extends Component { | |
getInitialState(){ | |
return { | |
title: 'Hello world!'; | |
} | |
} | |
render(){ | |
return ( |
This file contains hidden or 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
const { assign } = Object; | |
class Directors { | |
onFetch(directors) { | |
this.directorsHash = directors.reduce((memo, director) => | |
assign(memo, { [director.id]: director }) | |
, {}); | |
} | |
} |
This file contains hidden or 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
import _ from 'underscore'; | |
export function on(eventName){ | |
return function(target, name, descriptor){ | |
if(!target.events) { | |
target.events = {}; | |
} | |
if(_.isFunction(target.events)) { | |
throw new Error('The on decorator is not compatible with an events method'); | |
return; |
This file contains hidden or 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
// index.js | |
// by requiring `babel/register`, all of our successive `require`s will be Babel'd | |
require('babel/register'); | |
require('./server.js'); | |
// server.js | |
import express from 'express'; | |
let app = express(); | |
const PORT = 3000; |
This file contains hidden or 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
import React from 'react'; | |
function animateIn(Component){ | |
return class DecoratedComponent extends React.Component { | |
componentWillEnter(){ | |
// Do some swanky animation | |
} | |
render(){ | |
// Inherit all props |