From 2f8ae58f4f5cde892b4b6981a83a37edc1422a2c Mon Sep 17 00:00:00 2001 From: ditoaugusta Date: Tue, 24 Mar 2020 15:04:52 +0700 Subject: experiment: redux toolkit --- modern/src/SocketController.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modern/src/SocketController.js') diff --git a/modern/src/SocketController.js b/modern/src/SocketController.js index b89845f..10db17a 100644 --- a/modern/src/SocketController.js +++ b/modern/src/SocketController.js @@ -1,6 +1,6 @@ import { Component } from 'react'; import { connect } from 'react-redux'; -import { updateDevices, updatePositions } from './actions'; +import { positionsActions, devicesActions } from 'store/modules'; const displayNotifications = events => { if ("Notification" in window) { @@ -31,10 +31,10 @@ class SocketController extends Component { socket.onmessage = (event) => { const data = JSON.parse(event.data); if (data.devices) { - this.props.dispatch(updateDevices(data.devices)); + this.props.dispatch(devicesActions.update(data.devices)); } if (data.positions) { - this.props.dispatch(updatePositions(data.positions)); + this.props.dispatch(positionsActions.update(data.positions)); } if (data.events) { displayNotifications(data.events); @@ -46,7 +46,7 @@ class SocketController extends Component { fetch('/api/devices').then(response => { if (response.ok) { response.json().then(devices => { - this.props.dispatch(updateDevices(devices)); + this.props.dispatch(devicesActions.update(devices)); }); } this.connectSocket(); -- cgit v1.2.3