Skip to content

Commit

Permalink
fix: onChange throw error handler sooner in instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickheng committed Feb 13, 2017
1 parent 8d6df62 commit c64ef1c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ class State {
* @param {function} callback Callback
*/
onChange (query, callback) {
if (typeof callback !== 'function') {
throw new TypeError('Signal.onChange() : Second argument must be a Function')
}

const { container, containerId, splittedQuery } = this._parseStateQuery(query)

let signalId = containerId
Expand All @@ -124,10 +128,6 @@ class State {
container.signals[signalId] = new Signal()
}

if (typeof callback !== 'function') {
throw new TypeError('Signal.onChange() : Second argument must be a Function')
}

container.signals[signalId].add(callback)
}

Expand Down

0 comments on commit c64ef1c

Please sign in to comment.