Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: async useSubscription #142

Closed
JarvisH opened this issue Oct 14, 2021 · 1 comment · Fixed by #143
Closed

Question: async useSubscription #142

JarvisH opened this issue Oct 14, 2021 · 1 comment · Fixed by #143
Labels
✨ enhancement New feature or request

Comments

@JarvisH
Copy link

JarvisH commented Oct 14, 2021

I have a working App.vue root using composition api:

// App.vue root
{
    setup() {
        useClient(config)
        useSubscription(options)
    }
}

I need to make an async check for authorization before calling useSubscription to prevent excessive error-logs in the Backend.
(Of course authorization is already implemented in the connectionParams for the SubscriptionClient)

I am aware of the async limitations and suspense component when using the composition api, but I would still like to call useSubscription in the App.vue root. Is this even possible? Or is the only option to move useSubscription to a child component?

I noticed that useQuery has an option fetchOnMount which solves the same problem for queries, but an equivalent is not available for useSubscription.

@logaretm
Copy link
Owner

logaretm commented Oct 17, 2021

You are right, there isn't a way to support "lazy" initialization of subscriptions.

Seems like a worthy addition, thanks for suggesting this.

As a workaround you could call pause on mounted.

const { pause } = useSubscription(...);
onMounted(pause);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants