Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Commit

Permalink
move redeceState export back to commonJS and exclude from babel trans…
Browse files Browse the repository at this point in the history
…pile
  • Loading branch information
askmike committed Jun 28, 2018
1 parent d4a69d3 commit ca4f4d6
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 38 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion web/state/gekkoManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const promisify = require('tiny-promisify');
const broadcast = require('./cache').get('broadcast');
const Logger = require('./logger');
const pipelineRunner = promisify(require('../../core/workers/pipeline/parent'));
const reduceState = require('./reduceState');
const reduceState = require('./reduceState.js');

const GekkoManager = function() {
this.gekkos = {};
Expand Down Expand Up @@ -99,6 +99,7 @@ GekkoManager.prototype.handleRawEvent = function(id) {

GekkoManager.prototype.handleGekkoEvent = function(id, event) {
this.gekkos[id] = reduceState(this.gekkos[id], event);
console.log(event);
broadcast({
type: 'gekko_event',
id,
Expand Down
7 changes: 3 additions & 4 deletions web/state/reduceState.mjs → web/state/reduceState.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Redux/vuex inspired reducer, reduces an event into a gekko state.
// NOTE: this is used by the backend as well as the frontend.

const moment = require('moment');

const skipInitialEvents = ['marketUpdate'];
const skipLatestEvents = ['marketStart'];
const trackAllEvents = ['tradeCompleted', 'advice', 'roundtrip'];
Expand All @@ -13,7 +11,7 @@ const reduce = (state, event) => {

state = {
...state,
latestUpdate: moment()
latestUpdate: new Date()
}

if(trackAllEvents.includes(type)) {
Expand Down Expand Up @@ -65,4 +63,5 @@ const reduce = (state, event) => {
return state;
}

export default reduce;
// export default reduce;
module.exports = reduce;
4 changes: 4 additions & 0 deletions web/vue/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module.exports = {
presets: [
'@vue/app'
],
ignore: [
'node_modules',
'../state/reduceState.js'
]
}
126 changes: 95 additions & 31 deletions web/vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion web/vue/src/store/modules/gekkos/mutations.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue'
import reduceState from '../../../../../state/reduceState'
// import reduceState from '../../../../../state/reduceState.js'
const reduceState = require('../../../../../state/reduceState');

export const syncGekkos = (state, gekkos) => {
state.gekkos = gekkos;
Expand Down

0 comments on commit ca4f4d6

Please sign in to comment.