-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { isPreview } from './turbo.js' | |
export class TurboStreamSourceElement extends HTMLElement { | ||
static cable | ||
static channelClass | ||
static delayedUnsubscribe | ||
|
||
async connectedCallback() { | ||
connectStreamSource(this) | ||
|
@@ -48,7 +49,15 @@ export class TurboStreamSourceElement extends HTMLElement { | |
listener() | ||
} | ||
this.listeners.length = 0 | ||
this.channel.disconnect() | ||
|
||
let ch = this.channel | ||
let delay = this.constructor.delayedUnsubscribe | ||
|
||
if (delay) { | ||
setTimeout(() => ch.disconnect(), delay) | ||
} else { | ||
ch.disconnect() | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
palkan
Author
Member
|
||
} | ||
} | ||
|
||
|
@palkan - If the default value is
delayedUnsubscribe =0
, is there any need for a conditional here?just use