Skip to content
This repository was 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
zhurlik wants to merge 2 commits intoadonisjs:developfrom
zhurlik:develop
Open

To fix Use adonis-websocket-client with Web Worker #74#75
zhurlik wants to merge 2 commits intoadonisjs:developfrom
zhurlik:develop

Conversation

@zhurlik
Copy link

@zhurlik zhurlik commented Jan 30, 2021

#74


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