Skip to content

Instantly share code, notes, and snippets.

@nicohvi

nicohvi/api.js

Created Jan 10, 2018
Embed
What would you like to do?
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