web-push icon indicating copy to clipboard operation
web-push copied to clipboard

Support multiple instances

Open lokshunhung opened this issue 1 year ago • 1 comments

Goal

Resolves #876

Implementation

  • Instead of having a module-scoped gcmAPIKey and vapidDetails in src/web-push-lib.js, we change those to instance properties of a WebPushLib class instance.
  • When re-exporting the setGCMAPIKey, setVapidDetails, generateRequestDetails for the global instance of WebPushLib, we need to .bind() the methods to retain the this context.
  • Also export the WebPushLib constructor so users can create multiple instances instead of just using the global instance.

lokshunhung avatar Feb 20 '24 03:02 lokshunhung