Skip to content

Commit 131919e

Browse files
committed
fix: Use always the latest channel in use_radio
1 parent b375b66 commit 131919e

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dioxus-radio"
3-
version = "0.5.1"
3+
version = "0.5.2"
44
edition = "2021"
55
description = "Fully-typed global state management with a topics subscription system for Dioxus 🧬"
66
readme = "./README.md"

src/hooks/use_radio.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,20 @@ where
479479
{
480480
let station = use_context::<RadioStation<Value, Channel>>();
481481

482-
use_hook(|| {
483-
let antenna = RadioAntenna::new(channel, station, ReactiveContext::current().unwrap());
482+
let mut radio = use_hook(|| {
483+
let antenna = RadioAntenna::new(
484+
channel.clone(),
485+
station,
486+
ReactiveContext::current().unwrap(),
487+
);
484488
Radio::new(Signal::new(antenna))
485-
})
489+
});
490+
491+
if radio.antenna.peek().channel != channel {
492+
radio.antenna.write().channel = channel;
493+
}
494+
495+
radio
486496
}
487497

488498
pub fn use_init_radio_station<Value, Channel>(

0 commit comments

Comments
 (0)