Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

To fix Use adonis-websocket-client with Web Worker #74 #75

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

zhurlik
Copy link

@zhurlik zhurlik commented Jan 30, 2021

#74

@@ -588,7 +588,8 @@ export default class Connection extends Emitter {
debug('creating socket connection on %s url', url)
}

this.ws = new window.WebSocket(url)
// eslint-disable-next-line no-undef
this.ws = (typeof window !== 'undefined') ? new window.WebSocket(url) : new WebSocket(url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this check at the top level and then re-use it everywhere?

const hasWindow = typeof window !== 'undefined'

hasWindow ? new window.Websocket(url) : WebSocket(url)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you go

@zhurlik zhurlik requested a review from thetutlage January 31, 2021 08:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants