react-nativesocket.iovirtual-realityreact-360

React VR - is it possible to implement real-time objects via socket.io?


I'm working on a project to showcase active RFID tracking of multiple devices in real-time. I've been looking at React VR as a possible way of showing users in remote locations the real-time positioning of the devices within a static, predefined space.

Essentially, I need to know if it is possible to use React VR with socket.io for pushing the real-time locations (x,y,z co-ords) to the frontend?


Solution

  • I've had success using Socket.io with React-VR to receive real-time Bitcoin transaction updates.

    package.json

    socket.io-client: "^2.0.4"
    

    Inside Redux store to load and store real-time data from coincap:

    ...
    import io from 'socket.io-client';
    ...
    export function loadTransactionsIntoState() {
      return function thunk(dispatch) {
        let socket = io.connect('http://socket.coincap.io', { jsonp: false })
        socket.on('trades', (tradeMsg) => {
          if (tradeMsg.coin == 'BTC') dispatch(addNewTransaction(tradeMsg.trade.data))
        })
      }
    }
    

    I originally had this connection statement inside a React-VR component which worked just as well.