web-push
web-push copied to clipboard
Support multiple instances
Goal
Resolves #876
Implementation
- Instead of having a module-scoped
gcmAPIKey
andvapidDetails
insrc/web-push-lib.js
, we change those to instance properties of aWebPushLib
class instance. - When re-exporting the
setGCMAPIKey
,setVapidDetails
,generateRequestDetails
for the global instance ofWebPushLib
, we need to.bind()
the methods to retain thethis
context. - Also export the
WebPushLib
constructor so users can create multiple instances instead of just using the global instance.