fix dioxus web

This commit is contained in:
Evan Almloff 2024-01-17 08:40:42 -06:00
parent d28221bdc2
commit 205a005142
3 changed files with 7 additions and 14 deletions

View file

@ -473,7 +473,7 @@ impl<T: Copy, S: Storage<SignalData<T>> + 'static> Deref for Signal<T, S> {
// First we create a closure that captures something with the Same in memory layout as Self (MaybeUninit<Self>).
let uninit_callable = MaybeUninit::<Self>::uninit();
// Then move that value into the closure. We assume that the closure now has a in memory layout of Self.
let uninit_closure = move || Self::read(unsafe { &*uninit_callable.as_ptr() }).clone();
let uninit_closure = move || *Self::read(unsafe { &*uninit_callable.as_ptr() });
// Check that the size of the closure is the same as the size of Self in case the compiler changed the layout of the closure.
let size_of_closure = std::mem::size_of_val(&uninit_closure);
@ -510,7 +510,7 @@ impl<T: 'static, S: Storage<SignalData<T>>> Drop for SignalSubscriberDrop<T, S>
/// A mutable reference to a signal's value.
///
/// T is the current type of the write
/// B is the dynamicly checked type of the write (RefMut)
/// B is the dynamically checked type of the write (RefMut)
/// S is the storage type of the signal
/// I is the type of the original signal
pub struct Write<T: 'static, B: MappableMut<T>, S: Storage<SignalData<I>>, I: 'static = T> {
@ -640,7 +640,7 @@ impl<T: Copy, S: Storage<SignalData<T>> + 'static> Deref for ReadOnlySignal<T, S
// First we create a closure that captures something with the Same in memory layout as Self (MaybeUninit<Self>).
let uninit_callable = MaybeUninit::<Self>::uninit();
// Then move that value into the closure. We assume that the closure now has a in memory layout of Self.
let uninit_closure = move || Self::read(unsafe { &*uninit_callable.as_ptr() }).clone();
let uninit_closure = move || *Self::read(unsafe { &*uninit_callable.as_ptr() });
// Check that the size of the closure is the same as the size of Self in case the compiler changed the layout of the closure.
let size_of_closure = std::mem::size_of_val(&uninit_closure);

View file

@ -60,7 +60,7 @@ use std::rc::Rc;
pub use crate::cfg::Config;
#[cfg(feature = "file_engine")]
pub use crate::file_engine::WebFileEngineExt;
use dioxus_core::{ComponentFunction, CrossPlatformConfig, VirtualDom};
use dioxus_core::CrossPlatformConfig;
use futures_util::{
future::{select, Either},
pin_mut, FutureExt, StreamExt,
@ -99,12 +99,8 @@ mod rehydrate;
/// wasm_bindgen_futures::spawn_local(app_fut);
/// }
/// ```
pub async fn run_with_props<
Component: ComponentFunction<Phantom, Props = Props>,
Props: Clone + 'static,
Phantom: 'static,
>(
dioxus_config: CrossPlatformConfig<Component, Props, Phantom>,
pub async fn run_with_props<Props: Clone + 'static>(
dioxus_config: CrossPlatformConfig<Props>,
web_config: Config,
) {
tracing::info!("Starting up");

View file

@ -8,10 +8,7 @@ pub struct WebPlatform;
impl<Props: Clone + 'static> PlatformBuilder<Props> for WebPlatform {
type Config = Config;
fn launch<Component: ComponentFunction<Phantom, Props = Props>, Phantom: 'static>(
config: CrossPlatformConfig<Component, Props, Phantom>,
platform_config: Self::Config,
) {
fn launch(config: CrossPlatformConfig<Props>, platform_config: Self::Config) {
wasm_bindgen_futures::spawn_local(async move {
crate::run_with_props(config, platform_config).await;
});