bluebot
Version:
A bitcoin trading bot for auto trading at various exchanges
33 lines (27 loc) • 713 B
JavaScript
import { get } from '../../../tools/ajax'
import store from '../../'
import { bus } from '../../../components/global/ws'
import _ from 'lodash'
const init = () => {
get('bluebots', (err, resp) => {
let watchers = _.filter(resp, {type: 'watcher'});
store.commit('syncWatchers', watchers);
});
}
const sync = () => {
bus.$on('new_bluebot', data => {
if(data.bluebot.type === 'watcher')
store.commit('addWatcher', data.bluebot);
});
const update = (data) => {
store.commit('updateWatcher', data);
}
bus.$on('update', update);
bus.$on('startAt', update);
bus.$on('lastCandle', update);
bus.$on('firstCandle', update);
}
export default function() {
init();
sync();
}