Skip to content

Commit

Permalink
ExperimentalAuth: add missing return false/true for event listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunanoordin committed Dec 10, 2024
1 parent 1834d3d commit 90fd175
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/lib-panoptes-js/src/experimental-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Input:
- listener: (function) function that will be called when event is broadcasted.
- _store: (optional) data store. See default globalStore.
Output:
- true if a listener is added for an event, false otherwise.
- true if an event listener is successfully added, false otherwise.
Side Effects:
- on success, _store's eventListeners will be updated.
Notes:
Expand Down Expand Up @@ -66,9 +66,10 @@ Input:
- listener: (function) function that would have been called when event is
broadcasted.
- _store: (optional) data store. See default globalStore.
Output: n/a
Output:
- true if an event listener is successfully removed, false otherwise.
Side Effects:
- _store's eventListeners will be updated.
- on success, _store's eventListeners will be updated.
Possible Errors: n/a
Notes:
- Attempts to remove non-existent listener are ignored.
Expand All @@ -80,11 +81,12 @@ function removeEventListener (eventType, listener, _store) {
// Check if the listener has already been registered for the event type.
if (!store.eventListeners[eventType] || !store.eventListeners[eventType]?.find(l => l === listener)) {
console.log(`Panoptes.js addEventListener: listener for event type '${eventType}' hasn't been registered.`)
return
return false
}

// Remove the listener for that event type.
store.eventListeners[eventType] = store.eventListeners[eventType].filter(l => l !== listener)
return true
}

/*
Expand Down

0 comments on commit 90fd175

Please sign in to comment.