Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Feb 9, 2024
1 parent 42adeb4 commit f330cdb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion std/src/utils/channel/use_listen_channel.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::future::Future;
use std::{future::Future, rc::Rc};

use async_broadcast::RecvError;
use dioxus::prelude::*;
Expand All @@ -14,7 +14,9 @@ pub fn use_listen_channel<MessageType: Clone + 'static, Handler>(
) where
Handler: Future<Output = ()> + 'static,
{
let action = use_hook(|| Rc::new(action));
use_memo_with_dependencies((channel,), move |(mut channel,)| {
to_owned![action];
spawn(async move {
let mut receiver = channel.receiver();
loop {
Expand Down
8 changes: 5 additions & 3 deletions std/src/utils/rw/use_rw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ impl<T> Clone for UseRw<T> {

impl<T> UseRw<T> {
pub fn read(&self) -> Result<RwLockReadGuard<'_, T>, UseRwError> {
self.value.read().read().map_err(|_| UseRwError::Poisoned)
let rw_lock = self.value.read();
rw_lock.read().map_err(|_| UseRwError::Poisoned)
}

pub fn write(&self, new_value: T) -> Result<(), UseRwError> {
let mut lock = self
let rw_lock = self
.value
.read()
.read();
let mut lock = rw_lock
.write()
.map_err(|_| UseRwError::Poisoned)?;
*lock = new_value;
Expand Down

0 comments on commit f330cdb

Please sign in to comment.