itaylor/redux-socket.io

incompatibility with middlewares based on function

hectorcenteno opened this issue · 1 comments

I have the following case:

  1. I'm using redux-thunk
  2. I have action creators that return functions insted of plain objects

redux-socket.io doesn't have this case into acount, so I get and error in:

function evaluate(action, option) {
    var type = action.type;

    var matched = false;
    if (typeof option === 'function') {
      // Test function
      matched = option(type, action);
    } else if (typeof option === 'string') {
      // String prefix
      matched = type.indexOf(option) === 0;
    } else if (Array.isArray(option)) {
      // Array of types
      matched = option.some(function (item) {
        return type.indexOf(item) === 0;
      });
    }
    return matched;
  }

Uncaught TypeError: Cannot read property 'indexOf' of undefined

Because when in the first line of the function var type = action.type; there is not type.

I just read this:
#17

I think there should be an annotation on the readme file. Thanks a lot !