Skip to content

Instantly share code, notes, and snippets.

@nicohvi
Created January 10, 2018 08:38
Show Gist options
  • Save nicohvi/74f9603d9fde41e3261633f6e051c03e to your computer and use it in GitHub Desktop.
Save nicohvi/74f9603d9fde41e3261633f6e051c03e to your computer and use it in GitHub Desktop.
import store from './store';
export default {
init () {
// hent no data elns
}
update (data) {
store.update(data);
}
}
const App = props => <h1>Hello world from App!</h1>;
export default App;
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();
}
// 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