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 * as RX from 'reactxp' | |
import Navigator, { Types, NavigatorDelegateSelector as DelegateSelector } from 'reactxp-navigation' | |
import { EventEmitter } from 'events' | |
const exampleStore = new EventEmitter() | |
export class App extends RX.Component<{}, { counter: number }> { | |
state = { counter: 0 } | |
private navigator: Navigator |
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
new webpack.optimize.CommonsChunkPlugin({ | |
name: 'someEntryFile', | |
minChunks (module, count) { | |
return module.resource && module.resource.indexOf('lodash') !== -1 && count > 1; | |
} | |
}); |
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
/** | |
* Internal helpers | |
*/ | |
// Predicates can return true/false or they can return an error message. | |
// true, null, undefined and empty string are considered a valid result | |
function isValid (result) { | |
return result === true || result === null || result === void 0 || result === ''; | |
} |
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
localhost:80 | |
gzip | |
ext .html | |
root /home/deploy/current/build/www | |
proxy /graphql localhost:3000 | |
rewrite /login { | |
to {path} /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
const t = require('tcomb'); | |
const Person = t.struct({ name: t.Str, money: t.Num }, 'Person'); | |
Person.prototype.pay = function (amount) { | |
return Person.update(this, { | |
money: { $set: this.money + t.Num(amount) } | |
}); | |
}; |
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
m.createComponent = function createClass (displayName, opts) { | |
const hooks = _.defaults(opts, hookDefaults); // Apply some defaults (excluded) | |
const methods = _.methods(_.omit(opts, hookNames)); // Get instance methods | |
const propTypes = createValidator(hooks.propTypes, displayName); // Create a prop type validator (excluded) | |
const Component = { | |
controller () { | |
const initialState = hooks.getInitialState() || {}; | |
const ctrl = { |
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
// Action definition signature | |
const Definition = t.struct({ | |
fn: t.Func, | |
displayName: t.maybe(t.Str), | |
inputs: t.maybe(t.Obj), | |
exits: t.maybe(t.Obj), | |
sync: t.maybe(t.Bool) | |
}); | |
cerebral.action = function cerebral$action (action) { |
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
function checkValue (msg, value, type) { | |
const check = t.validate(value, type); | |
if (!check.isValid()) { | |
console.error(msg + ' ' + check.firstError().message); | |
} | |
return value; | |
} | |
// This method accepts an object and returns a function that |
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
///////////// | |
// Factory // | |
///////////// | |
Kefir.model = function (store, tx) { | |
if (typeof tx !== 'function') tx = x => x; | |
const getset = function kefir$model (update) { | |
if (arguments.length > 0) { |
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
function sum (arr) { | |
return arr.reduce((x, i) => x + i, 0); | |
} | |
function mean (arr) { | |
return sum(arr) / arr.length; | |
} | |
function variance (arr) { | |
let m = mean(arr); |
NewerOlder