Created
March 6, 2020 16:26
-
-
Save stevschmid/e2c8b9474535c1085c8a56ddad2276a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import consumer from "./consumer" | |
let subscription | |
const unsubscribe = () => { | |
console.log('unsubscribe') | |
subscription.unsubscribe() | |
} | |
const DELAY_RESUBSCRIBE = 10 | |
const subscribe = () => { | |
console.log('subscribe') | |
subscription = consumer.subscriptions.create("TestChannel", { | |
connected() { | |
// Called when the subscription is ready for use on the server | |
console.log('connected') | |
setTimeout(() => { | |
unsubscribe() | |
setTimeout(() => subscribe(), DELAY_RESUBSCRIBE) | |
}, 3000) | |
}, | |
}) | |
} | |
subscribe() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment