2017-05-27 46 views

回答

0

只是寫了一個簡短的中間件,完美地工作。

const socketAuthenticator = (store) => (next) => (action) =>{ 
    if(action.type === "AUTHENTICATION_FULFILLED" || action.type === "REGISTRATION_FULFILLED") { 
     const token = action.payload.token; 
     const socket = store.getState().socket.socket 
     socket.emit('authenticate', { token }) 
    } 
    next(action) 
} 
相關問題