sch / redux-websocket-middleware

Declarative websockets for Redux
MIT License
17 stars 7 forks source link

This software cannot work, #5

Open DL1CB opened 6 years ago

DL1CB commented 6 years ago

in src/index.js

 connection.onmessage(function (data) {
    store.dispatch(createMessageAction(endpoint, data))
  })

connection does not have the function onmessage

should be someting like

 connection.socket.onmessage(function (data) {
    store.dispatch(createMessageAction(endpoint, data))
 })
knro commented 6 years ago

Yes that doesn't even at all, it needs to be this:

connection.socket.onmessage = function (data) {
        store.dispatch(createMessageAction(endpoint, data))
      }

      connection.socket.onopen = function () {
        store.dispatch(createConnectionAction(endpoint))
      }

      connection.socket.onclose = function () {
        store.dispatch(createDisonnectionAction(endpoint))
      }

      connection.socket.onerror = function (error) {
        store.dispatch(createErrorAction(endpoint, error))
      }

Also, I don't understand these claims:

Was this a TODO? because the released version does not retry connection or do offline batching!