const { connect } = require('preact-redux'); const CrypList = require('./cryp.list.component'); const actions = require('./../actions'); const addState = connect( function receiveState(state) { const { ws, cryps, selectedCryps } = state; function sendInstanceJoin() { if (selectedCryps.length) { return ws.sendInstanceJoin(selectedCryps); } return false; } function sendCrypSpawn(name) { return ws.sendCrypSpawn(name); } return { cryps, selectedCryps, sendInstanceJoin, sendCrypSpawn }; }, function receiveDispatch(dispatch) { function setSelectedCryps(crypIds) { dispatch(actions.setSelectedCryps(crypIds)); } return { setSelectedCryps }; } ); module.exports = addState(CrypList);