Created
January 10, 2018 08:38
-
-
Save nicohvi/74f9603d9fde41e3261633f6e051c03e to your computer and use it in GitHub Desktop.
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 store from './store'; | |
export default { | |
init () { | |
// hent no data elns | |
} | |
update (data) { | |
store.update(data); | |
} | |
} |
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 App = props => <h1>Hello world from App!</h1>; | |
export default App; |
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 store from './store'; | |
import api form './api'; | |
import App from './app'; | |
export default function init() { | |
const $app = $('#js-app'); | |
if($app.length === 0) return; | |
store.props.onValue(props => <App {...props} />, $app[0]); | |
api.init(); | |
} |
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
// eventstrømmer. Jeg bruker Bacon.js, men RxJs kan også brukes f.eks. | |
const initialValues = { | |
key: 'value' | |
} | |
let busCache = {}; | |
function bus (name) { | |
return busCache[name] = busCache[name] || new B.bus(); | |
} | |
function push (name, data) { | |
bus(name).push(data); | |
} | |
const props = B.update(initialValues, [bus('update'), (state, data) => {...state, ...data}]) | |
return { | |
props, | |
update: data => push('update', data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment