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
var { Store, Dispatcher } = require('./dist/emf') | |
var myDispatcher = new Dispatcher() | |
class DogStore extends Store { | |
getInitialState() { | |
return { | |
dog: 2 | |
} | |
} |
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 TaskStore { | |
constructor() { | |
this.bindActions(TaskActions) | |
} | |
static getImmutableState() { | |
var state = this.getState() | |
// do something with state. |
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
λ node_modules/6to5/bin/6to5-node broken-tco.js | |
{ yes: 1, '[object Object]': 2, no: 1 } | |
λ cat node_modules/6to5/package.json | grep version | |
"version": "3.5.0", | |
λ cat broken-tco.js | |
function format(x) { | |
return x.toUpperCase() | |
} |
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
"use strict"; | |
var _tailCall = (function () { | |
function Tail(func, args, context) { | |
this.func = func; | |
this.args = args; | |
this.context = context; | |
} | |
Tail.prototype._isTailDescriptor = true; | |
var isRunning = false; |
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 MyActions { | |
asyncAction() { | |
setTimeout(() => { | |
this.dispatch('foo') | |
}) | |
} | |
} | |
var myActions = alt.createActions(MyActions) |
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 render(SomeElement, state) { | |
if (typeof window === 'undefined') { | |
let htmlMarkup = React.renderToString(React.createElement(SomeElement, state)) | |
return Iso.render(htmlMarkup, state, { id: 'hello' }) | |
} else { | |
Iso.on('id', 'hello', function (state, meta, node) { | |
React.render(React.createElement(SomeElement, state), node) | |
}) | |
} |
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
var Alt = require('alt') | |
var alt = new Alt() | |
function S() { } | |
S.getUserById = function (id) { | |
var { users } = this.getState() | |
if (users[id]) { | |
return users[id] | |
} else { |
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
var Alt = require('alt') | |
var alt = new Alt() | |
function UserActions() { | |
this.generateActions('getUser', 'addUser') | |
} | |
var ua = alt.createActions(UserActions) |
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
var Alt = require('alt') | |
function Action() { | |
} | |
Action.prototype.a = function () { | |
return 2 | |
} | |
var a = new Alt().createActions(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
import Alt from 'alt'; | |
import DispatcherRecorder from 'alt/utils/DispatcherRecorder'; | |
let alt = new Alt(); | |
let recorder = new DispatcherRecorder(alt); | |
// setup actions and store | |
function Actions() { this.generateActions('a', 'b', 'c'); } |
OlderNewer