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 Helpers { | |
currentHP(db) { return db.PlayerInfo.CurrHP } | |
noCurrentHPGain(db) { return db.PlayerInfo.CurrentHPGain == 0.0 } | |
radiation(db) { return db.PlayerInfo.TotalDamages[5].Value } | |
aidItems(db) { return db.Inventory['48'] } | |
radiationMoreThan(rads) { | |
return db => { | |
this.radiation(db) > rads; | |
}; |
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
/** | |
* @param {Function} fn Function to curry. | |
* @param {Number} lenght of the arguments required to invoke the function. | |
* @returns {Function} The currified function. | |
*/ | |
const curry = (fn, length = fn.length) => function currified(...args) { | |
if (args.length === 0) { | |
return currified; | |
} | |
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
const merge = (obj, src) => { | |
let res = obj; | |
for (let k of Object.keys(src)) { | |
if (res[k] === src[k]) { | |
continue; | |
} | |
if (typeof src[k] === 'object' && src[k] !== null && src[k].constructor === Object) { | |
let sub = res[k]; |
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
const React = require('react'); | |
const { TransitionSpring } = require('react-motion'); | |
const Router = require('react-router'); | |
const RouteTransition = React.createClass({ | |
propTypes: { | |
pathname: React.PropTypes.string.isRequired | |
}, | |
willEnter() { |
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
const Authenticated = function(isAuthenticated) { | |
return React.createClass({ | |
displayName: 'Authenticated', | |
statics: { | |
willTransitionTo(transition) { | |
if (!isAuthenticated()) { | |
transition.redirect('login'); | |
} | |
}, |
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
import React from 'react'; | |
import Router from 'react-router'; | |
import _ from 'lodash'; | |
class MegaRouteHander extends React.Component { | |
static contextTypes = { | |
megaApi: React.PropTypes.object.isRequired, | |
routeDepth: React.PropTypes.number.isRequired, | |
router: React.PropTypes.func.isRequired | |
}; |
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 ThingRecord extends Immutable.Record({ | |
id: null, | |
someData: {} | |
}) {} | |
const thingSet = Immutable.fromJS(things); | |
const thingsOrderedMap = thingSet.reduce((r, v) => r.set(v.get('id'), | |
new ThingRecord(v)), | |
Immutable.OrderedMap() |
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
import { Actions } from 'flummox'; | |
export default class TodoActions extends Actions { | |
constructor(db) { | |
super(); | |
this.db = db; | |
} | |
async create(model) { |
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.run(routes, Router.HistoryLocation, (Handler, state) => { | |
function render() { | |
var data = flux.stores.getAll(); | |
React.render(<Handler state={state} data={data} actions={flux.actions}/>, container); | |
} | |
_.each(state.routes, route => { | |
if (Array.isArray(route.handler.actions) { // handle all the fetching... or other static actions... | |
_.each(route.handler.actions, action => setTimeout(action.bind(null, state.params))); | |
} |
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.run((Handler, state) => { | |
log('route change', state); | |
function getData() { | |
var data = {}; | |
_each(ALL_STORES, (store) => { | |
data[store + 'Data'] = flux.store(store).getState(); | |
}); | |
return data; |