Add observe_and_get method

This commit is contained in:
bitfl0wer 2023-08-15 16:57:54 +02:00
parent 28ea95f4a4
commit d66807ed20
1 changed files with 9 additions and 0 deletions

View File

@ -223,6 +223,15 @@ impl GatewayHandle {
} }
} }
pub async fn observe_and_get<T: Updateable + Clone>(
&self,
object: Arc<RwLock<T>>,
) -> Arc<RwLock<T>> {
let channel = self.observe(object).await;
let object = channel.borrow().clone();
object
}
/// Sends an identify event to the gateway /// Sends an identify event to the gateway
pub async fn send_identify(&self, to_send: types::GatewayIdentifyPayload) { pub async fn send_identify(&self, to_send: types::GatewayIdentifyPayload) {
let to_send_value = serde_json::to_value(&to_send).unwrap(); let to_send_value = serde_json::to_value(&to_send).unwrap();