-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from matthunz/fix-signals
Fix reactivity after signals migration
- Loading branch information
Showing
11 changed files
with
109 additions
and
148 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use dioxus::prelude::*; | ||
use dioxus_spring::use_spring_ref; | ||
use log::LevelFilter; | ||
use std::time::Duration; | ||
|
||
fn app() -> Element { | ||
let mut signal = use_signal(|| 0.); | ||
let spring_ref = use_spring_ref(0f32, move |x| { | ||
signal.set(x) | ||
}); | ||
|
||
use_hook(move || { | ||
spring_ref.animate(1., Duration::from_secs(1)); | ||
}); | ||
|
||
use_effect(move || { | ||
log::info!("{}", signal()); | ||
}); | ||
|
||
rsx!() | ||
} | ||
|
||
fn main() { | ||
dioxus_logger::init(LevelFilter::Info).expect("failed to init logger"); | ||
|
||
dioxus_web::launch::launch_cfg(app, Default::default()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use dioxus::prelude::*; | ||
use dioxus_spring::use_spring_signal; | ||
use log::LevelFilter; | ||
use std::time::Duration; | ||
|
||
fn app() -> Element { | ||
let (value, value_spring) = use_spring_signal(0f32); | ||
|
||
use_hook(move || { | ||
value_spring.animate(1., Duration::from_secs(1)); | ||
}); | ||
|
||
use_effect(move || { | ||
log::info!("{}", value()); | ||
}); | ||
|
||
rsx!() | ||
} | ||
|
||
fn main() { | ||
dioxus_logger::init(LevelFilter::Info).expect("failed to init logger"); | ||
|
||
dioxus_web::launch::launch_cfg(app, Default::default()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.