made with esnextbin
Last active
December 18, 2016 18:30
-
-
Save voronianski/bb2ca658548c1a5d438924fd03273c37 to your computer and use it in GitHub Desktop.
esnextbin sketch
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
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
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
console.log('a'); | |
import createStoreEmitter from 'store-emitter'; | |
const initialState = { | |
count: 1 | |
}; | |
function modifier (action, state) { | |
if (action.type === 'increment') { | |
state.count = state.count+1; | |
} | |
} | |
const store = createStoreEmitter(modifier, initialState); | |
store.on('increment', (action, state, oldState) => { | |
console.log(action, state, oldState) | |
}); | |
store({type: 'increment'}); |
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
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"store-emitter": "2.2.0" | |
} | |
} |
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
'use strict'; | |
var _storeEmitter = require('store-emitter'); | |
var _storeEmitter2 = _interopRequireDefault(_storeEmitter); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
console.log('a'); | |
var initialState = { | |
count: 1 | |
}; | |
function modifier(action, state) { | |
if (action.type === 'increment') { | |
state.count = state.count + 1; | |
} | |
} | |
var store = (0, _storeEmitter2.default)(modifier, initialState); | |
store.on('increment', function (action, state, oldState) { | |
console.log(action, state, oldState); | |
}); | |
store({ type: 'increment' }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment