Skip to content

How to use StompJS in a SharedWorker #337

@silentiumNoxe

Description

@silentiumNoxe

The standard UMD header does not work within Shared Workers. Shared Workers run in a browser, however, these do not have access to window.

if (typeof exports !== "undefined" && exports !== null) {
  exports.Stomp = Stomp;
}

if (typeof window !== "undefined" && window !== null) {
  window.Stomp = Stomp;
} else if (!exports) {
  self.Stomp = Stomp;
}

The above block would give undefined exports.

To fix this problem, please define the following before including stompjs.

 self.exports = {};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions