Q:

Difference Between a Redux middleware and reducer accepting all actions

In my redux project, I want to check something ( for example network connection ) in every action dispatch. Should I implement using a reducer which accepts all type of actions( without type checking ) as given below
export default (state = defaultState) => ({
    ...state,
    neworkStatus: navigator.onLine
})

or with a middleware.
const NetworkMiddleware = store => next => (action) => {
    const result = next(action)
    const state = store.getState()
    if (navigator.onLine && !state.NetworkDetector.networkStatus) next({ type: 'NETWORK_SUCCESS' })
    if (!navigator.onLine && state.NetworkDetector.networkStatus) next({ type: 'NETWORK_ERROR' })
    return result
}

export default NetworkMiddleware;

what is the difference between these two implementations

A:

It provides a third-party extension point between dispatching an
  action, and the moment it reaches the reducer. People use Redux
  middleware for logging, crash reporting, talking to an asynchronous
  API, routing, and more.

I think it would be better to use a middleware to analyse network activity. Read these Redux docs for further information.

