const { connect } = require('preact-redux'); const actions = require('../actions'); const Instance = require('./instance.component'); const addState = connect( function receiveState(state) { const { ws, instance, account, activeVar, activeCryp } = state; function sendInstanceReady() { return ws.sendInstanceReady(instance.instance); } function sendVboxApply(crypId, i) { return ws.sendVboxApply(instance.instance, crypId, i); } return { instance, account, sendInstanceReady, sendVboxApply, activeVar, activeCryp }; }, function receiveDispatch(dispatch) { function quit() { dispatch(actions.setInstance(null)); } function setInfo(item, value) { dispatch(actions.setInfo([item, value])); } function setActiveVar(value) { dispatch(actions.setActiveVar(value)); } function setActiveCryp(value) { dispatch(actions.setActiveCryp(value)); } function clearInfo() { return dispatch(actions.setInfo([])); } return { quit, clearInfo, setInfo, setActiveVar, setActiveCryp }; } ); module.exports = addState(Instance);