-
Notifications
You must be signed in to change notification settings - Fork 37
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
BroadcasterSignal.second() #14
Comments
I'm curious what your use case is, why do you need the first changed value, and why do you only need 1 value? |
Here is my use case scs/substrate-api-client#48. I am doing async await on websocket hence i only need one value, if not it will await forever. I need to pass the websocket result to node module and to be used in react. |
I took a look at your code, and it seems you aren't using Signals properly. A Signal is supposed to be for a value which changes over time. So for example, you might have a But in your case, you just want to retrieve a single value. So you should use async fn _get_request(url: String, jsonreq: String) -> Result<String, &'static str> {
let (sender, receiver) = oneshot::channel();
rpc::get(url, jsonreq, sender);
let result = receiver.await.unwrap();
result
} This will be more efficient than using Signals, and it also matches with what you're trying to do. |
BroadcasterSignal.first() returns the initial value of the Mutable. However, I want to return the first changed value of the Mutable. I can't use BroadcasterSignal.for_each() or BroadcasterSignal.map as they do not terminate. It would be good also to be able to pass comparsion function to end the poll.
The text was updated successfully, but these errors were encountered: