Replies: 2 comments
-
I probably made a misstake in setting up the subscription. I used
ctx is my state, which has a |
Beta Was this translation helpful? Give feedback.
-
You should probally consider using a
A subscriptions function is called once and then the stream will being polled until it's complete like regular Rust code. The polling won't result in the same piece of code being run twice as this would likely break Rust's safety guarantees. I wonder if you have multiple browser tabs open with your site, or more likely if your using React we may be creating the subscription twice in development due to how |
Beta Was this translation helpful? Give feedback.
-
Hi,
Sorry for all the questions :)
I have a subscription via RSPC (using Tauri) and I'm trying to send a message through it, but outside of the
.subscription(
callback (from another thread doing background processing work). I've tried various was of usingmpsc
patterns from various attack points.My initial plan was to create a receiver and attach it in
subscription
, something likeBut it seems this won't work due to the "single consumer" part, because it looks like the subscription get's called twice internally (one to get the output format? One once in running?).
I tried doing a more advanced logic where I the first time create the receiver, and then the second time re-use the same but then it falters on
no two async blocks, even if identical, have the same type
because the async blocks aren't actually the same.My second (or more like 10th) try was to setup a loop inside rspc_tauri2 and pass it the receiver:
This works, in the sense that a message get sent to the front-end but it's not send using the subscriptions ID (which means). I can work around that, by assuming that the first key of the HashMap is the subscription, but we're getting down into hacky territory :)
Regards,
Niklas
Beta Was this translation helpful? Give feedback.
All reactions