Skip to content

Commit

Permalink
fix(parseMessage): Add check before getting event in getEventHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermelimak committed Mar 8, 2017
1 parent c705fcf commit 11e6a3c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/shared/parseMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import Event from 'src/shared/event'
* @param {Object} handlers Handlers list to find the handler in.
* @return {Func} Handler associated with the event type
*/
const getEventHandler = (e, handlers) => handlers.find(i => i.type === e.type).handler.bind(this)
const getEventHandler = (e, handlers) => {
const event = handlers.find(i => i.type === e.type)

if (!event) return undefined

return event.handler.bind(this)
}

/**
* Create event instance with strMessage and call the event handler if
Expand Down

0 comments on commit 11e6a3c

Please sign in to comment.