Make benches compile
This commit is contained in:
9 files changed
+60
-62
No files matched your search
+4
-2
@@ -25,7 +25,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// We only have one list of clients for the whole app, so we can use a global signal.
|
/// We only have one list of clients for the whole app, so we can use a global signal.
|
||||||
static CLIENTS: GlobalSignal<Vec<Client>> = Signal::global(|| Vec::new());
|
static CLIENTS: GlobalSignal<Vec<Client>> = Signal::global(Vec::new);
|
||||||
|
|
||||||
struct Client {
|
struct Client {
|
||||||
first_name: String,
|
first_name: String,
|
||||||
@@ -93,7 +93,9 @@ fn ClientAdd() -> Element {
|
|||||||
oninput: move |e| first_name.set(e.value()),
|
oninput: move |e| first_name.set(e.value()),
|
||||||
|
|
||||||
// when the form mounts, focus the first name input
|
// when the form mounts, focus the first name input
|
||||||
onmounted: move |e| {e.inner().set_focus(true);},
|
onmounted: move |e| async move {
|
||||||
|
_ = e.inner().set_focus(true).await;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ fn main() {
|
|||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let mut value = use_signal(|| 0);
|
let mut value = use_signal(|| 0);
|
||||||
let mut depth = use_signal(|| 0 as usize);
|
let mut depth = use_signal(|| 0_usize);
|
||||||
let items = use_memo(move || (0..depth()).map(|f| f as _).collect::<Vec<isize>>());
|
let items = use_memo(move || (0..depth()).map(|f| f as _).collect::<Vec<isize>>());
|
||||||
|
|
||||||
let state = use_memo(move || value() + 1);
|
let state = use_memo(move || value() + 1);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ fn main() {
|
|||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let mut state = use_signal(|| 0);
|
let mut state = use_signal(|| 0);
|
||||||
let mut depth = use_signal(|| 1 as usize);
|
let mut depth = use_signal(|| 1_usize);
|
||||||
|
|
||||||
if depth() == 5 {
|
if depth() == 5 {
|
||||||
return rsx! {
|
return rsx! {
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ struct TodoItem {
|
|||||||
const STYLE: &str = include_str!("./assets/todomvc.css");
|
const STYLE: &str = include_str!("./assets/todomvc.css");
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let mut todos = use_signal(|| HashMap::<u32, TodoItem>::new());
|
let mut todos = use_signal(HashMap::<u32, TodoItem>::new);
|
||||||
let filter = use_signal(|| FilterState::All);
|
let filter = use_signal(|| FilterState::All);
|
||||||
|
|
||||||
let active_todo_count =
|
let active_todo_count =
|
||||||
|
|||||||
@@ -13,12 +13,14 @@ fn main() {
|
|||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let mut focused = use_signal(|| true);
|
let mut focused = use_signal(|| true);
|
||||||
|
|
||||||
use_wry_event_handler(move |event, _| match event {
|
use_wry_event_handler(move |event, _| {
|
||||||
WryEvent::WindowEvent {
|
if let WryEvent::WindowEvent {
|
||||||
event: WindowEvent::Focused(new_focused),
|
event: WindowEvent::Focused(new_focused),
|
||||||
..
|
..
|
||||||
} => focused.set(*new_focused),
|
} = event
|
||||||
_ => {}
|
{
|
||||||
|
focused.set(*new_focused)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
rsx! {
|
rsx! {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ fn tui_update(c: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Props, PartialEq)]
|
#[derive(Props, PartialEq, Clone)]
|
||||||
struct BoxProps {
|
struct BoxProps {
|
||||||
x: usize,
|
x: usize,
|
||||||
y: usize,
|
y: usize,
|
||||||
@@ -65,15 +65,15 @@ struct BoxProps {
|
|||||||
alpha: f32,
|
alpha: f32,
|
||||||
}
|
}
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn Box(cx: ScopeState<BoxProps>) -> Element {
|
fn Box(props: BoxProps) -> Element {
|
||||||
let count = use_signal(|| 0);
|
let count = use_signal(|| 0);
|
||||||
|
|
||||||
let x = cx.props.x * 2;
|
let x = props.x * 2;
|
||||||
let y = cx.props.y * 2;
|
let y = props.y * 2;
|
||||||
let hue = cx.props.hue;
|
let hue = props.hue;
|
||||||
let display_hue = cx.props.hue as u32 / 10;
|
let display_hue = props.hue as u32 / 10;
|
||||||
let count = count.get();
|
let count = count();
|
||||||
let alpha = cx.props.alpha + (count % 100) as f32;
|
let alpha = props.alpha + (count % 100) as f32;
|
||||||
|
|
||||||
rsx! {
|
rsx! {
|
||||||
div {
|
div {
|
||||||
@@ -88,24 +88,24 @@ fn Box(cx: ScopeState<BoxProps>) -> Element {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Props, PartialEq)]
|
#[derive(Props, PartialEq, Clone)]
|
||||||
struct GridProps {
|
struct GridProps {
|
||||||
size: usize,
|
size: usize,
|
||||||
update_count: usize,
|
update_count: usize,
|
||||||
}
|
}
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn Grid(cx: ScopeState<GridProps>) -> Element {
|
fn Grid(props: GridProps) -> Element {
|
||||||
let size = cx.props.size;
|
let size = props.size;
|
||||||
let count = use_signal(|| 0);
|
let mut count = use_signal(|| 0);
|
||||||
let counts = use_signal(|| vec![0; size * size]);
|
let mut counts = use_signal(|| vec![0; size * size]);
|
||||||
|
|
||||||
let ctx: TuiContext = cx.consume_context().unwrap();
|
let ctx: TuiContext = consume_context();
|
||||||
if *count.get() + cx.props.update_count >= (size * size) {
|
if count() + props.update_count >= (size * size) {
|
||||||
ctx.quit();
|
ctx.quit();
|
||||||
} else {
|
} else {
|
||||||
for _ in 0..cx.props.update_count {
|
for _ in 0..props.update_count {
|
||||||
counts.with_mut(|c| {
|
counts.with_mut(|c| {
|
||||||
let i = *count.current();
|
let i = count();
|
||||||
c[i] += 1;
|
c[i] += 1;
|
||||||
c[i] %= 360;
|
c[i] %= 360;
|
||||||
});
|
});
|
||||||
@@ -121,44 +121,34 @@ fn Grid(cx: ScopeState<GridProps>) -> Element {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
flex_direction: "column",
|
flex_direction: "column",
|
||||||
(0..size).map(|x|
|
for x in 0..size {
|
||||||
{
|
div {
|
||||||
rsx! {
|
width: "100%",
|
||||||
div{
|
height: "100%",
|
||||||
width: "100%",
|
flex_direction: "row",
|
||||||
height: "100%",
|
for y in 0..size {
|
||||||
flex_direction: "row",
|
Box {
|
||||||
(0..size).map(|y|
|
key: "{x}-{y}",
|
||||||
{
|
x: x,
|
||||||
let alpha = y as f32*100.0/size as f32 + counts.read()[x*size + y] as f32;
|
y: y,
|
||||||
let key = format!("{}-{}", x, y);
|
alpha: 100.0,
|
||||||
rsx! {
|
hue: y as f32*100.0/size as f32 + counts.read()[x*size + y] as f32,
|
||||||
Box{
|
|
||||||
x: x,
|
|
||||||
y: y,
|
|
||||||
alpha: 100.0,
|
|
||||||
hue: alpha,
|
|
||||||
key: "{key}",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app(cx: ScopeState<GridProps>) -> Element {
|
fn app(props: GridProps) -> Element {
|
||||||
rsx! {
|
rsx! {
|
||||||
div{
|
div{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
Grid{
|
Grid{
|
||||||
size: cx.props.size,
|
size: props.size,
|
||||||
update_count: cx.props.update_count,
|
update_count: props.update_count,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ pub fn launch_cfg(app: fn() -> Element, cfg: Config) {
|
|||||||
launch_vdom_cfg(VirtualDom::new(app), cfg)
|
launch_vdom_cfg(VirtualDom::new(app), cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn launch_cfg_with_props<P: Clone + 'static>(app: fn(P) -> Element, props: P, cfg: Config) {
|
||||||
|
launch_vdom_cfg(VirtualDom::new_with_props(app, props), cfg)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn launch_vdom_cfg(vdom: VirtualDom, cfg: Config) {
|
pub fn launch_vdom_cfg(vdom: VirtualDom, cfg: Config) {
|
||||||
dioxus_html::set_event_converter(Box::new(events::SerializedHtmlEventConverter));
|
dioxus_html::set_event_converter(Box::new(events::SerializedHtmlEventConverter));
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ fn key_down() {
|
|||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let render_count = use_signal(|| 0);
|
let render_count = use_signal(|| 0);
|
||||||
let mut render_count_handle = render_count.clone();
|
let mut render_count_handle = render_count;
|
||||||
let tui_ctx: TuiContext = consume_context();
|
let tui_ctx: TuiContext = consume_context();
|
||||||
|
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
@@ -77,7 +77,7 @@ fn mouse_down() {
|
|||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let render_count = use_signal(|| 0);
|
let render_count = use_signal(|| 0);
|
||||||
let tui_ctx: TuiContext = consume_context();
|
let tui_ctx: TuiContext = consume_context();
|
||||||
let mut render_count_handle = render_count.clone();
|
let mut render_count_handle = render_count;
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
PollN::new(2).await;
|
PollN::new(2).await;
|
||||||
render_count_handle.with_mut(|x| *x + 1);
|
render_count_handle.with_mut(|x| *x + 1);
|
||||||
@@ -113,7 +113,7 @@ fn mouse_up() {
|
|||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let render_count = use_signal(|| 0);
|
let render_count = use_signal(|| 0);
|
||||||
let tui_ctx: TuiContext = consume_context();
|
let tui_ctx: TuiContext = consume_context();
|
||||||
let mut render_count_handle = render_count.clone();
|
let mut render_count_handle = render_count;
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
PollN::new(3).await;
|
PollN::new(3).await;
|
||||||
render_count_handle.with_mut(|x| *x + 1);
|
render_count_handle.with_mut(|x| *x + 1);
|
||||||
@@ -151,7 +151,7 @@ fn mouse_enter() {
|
|||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let render_count = use_signal(|| 0);
|
let render_count = use_signal(|| 0);
|
||||||
let mut render_count_handle = render_count.clone();
|
let mut render_count_handle = render_count;
|
||||||
let tui_ctx: TuiContext = consume_context();
|
let tui_ctx: TuiContext = consume_context();
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
PollN::new(3).await;
|
PollN::new(3).await;
|
||||||
@@ -191,7 +191,7 @@ fn mouse_exit() {
|
|||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let render_count = use_signal(|| 0);
|
let render_count = use_signal(|| 0);
|
||||||
let tui_ctx: TuiContext = consume_context();
|
let tui_ctx: TuiContext = consume_context();
|
||||||
let mut render_count_handle = render_count.clone();
|
let mut render_count_handle = render_count;
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
PollN::new(3).await;
|
PollN::new(3).await;
|
||||||
render_count_handle.with_mut(|x| *x + 1);
|
render_count_handle.with_mut(|x| *x + 1);
|
||||||
@@ -230,7 +230,7 @@ fn mouse_move() {
|
|||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let render_count = use_signal(|| 0);
|
let render_count = use_signal(|| 0);
|
||||||
let tui_ctx: TuiContext = consume_context();
|
let tui_ctx: TuiContext = consume_context();
|
||||||
let mut render_count_handle = render_count.clone();
|
let mut render_count_handle = render_count;
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
PollN::new(3).await;
|
PollN::new(3).await;
|
||||||
render_count_handle.with_mut(|x| *x + 1);
|
render_count_handle.with_mut(|x| *x + 1);
|
||||||
@@ -269,7 +269,7 @@ fn wheel() {
|
|||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let render_count = use_signal(|| 0);
|
let render_count = use_signal(|| 0);
|
||||||
let tui_ctx: TuiContext = consume_context();
|
let tui_ctx: TuiContext = consume_context();
|
||||||
let mut render_count_handle = render_count.clone();
|
let mut render_count_handle = render_count;
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
PollN::new(3).await;
|
PollN::new(3).await;
|
||||||
render_count_handle.with_mut(|x| *x + 1);
|
render_count_handle.with_mut(|x| *x + 1);
|
||||||
@@ -309,7 +309,7 @@ fn click() {
|
|||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let render_count = use_signal(|| 0);
|
let render_count = use_signal(|| 0);
|
||||||
let tui_ctx: TuiContext = consume_context();
|
let tui_ctx: TuiContext = consume_context();
|
||||||
let mut render_count_handle = render_count.clone();
|
let mut render_count_handle = render_count;
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
PollN::new(3).await;
|
PollN::new(3).await;
|
||||||
render_count_handle.with_mut(|x| *x + 1);
|
render_count_handle.with_mut(|x| *x + 1);
|
||||||
@@ -348,7 +348,7 @@ fn context_menu() {
|
|||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let render_count = use_signal(|| 0);
|
let render_count = use_signal(|| 0);
|
||||||
let tui_ctx: TuiContext = consume_context();
|
let tui_ctx: TuiContext = consume_context();
|
||||||
let mut render_count_handle = render_count.clone();
|
let mut render_count_handle = render_count;
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
PollN::new(3).await;
|
PollN::new(3).await;
|
||||||
render_count_handle.with_mut(|x| *x + 1);
|
render_count_handle.with_mut(|x| *x + 1);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//! Launch helper macros for fullstack apps
|
//! Launch helper macros for fullstack apps
|
||||||
|
#![allow(clippy::new_without_default)]
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user