Misc rename
This commit is contained in:
parent
d75930218c
commit
f4c13d18c7
|
@ -28,7 +28,7 @@ fn main() {
|
|||
#[component]
|
||||
fn Editor(cx: Scope) -> Element {
|
||||
// TODO: When selected entity is despawned, need to reset this to None
|
||||
let selected_entity = use_state_send(cx, || Option::<Entity>::None);
|
||||
let selected_entity = use_state_sendable(cx, || Option::<Entity>::None);
|
||||
|
||||
render! {
|
||||
node {
|
||||
|
@ -42,7 +42,7 @@ fn Editor(cx: Scope) -> Element {
|
|||
}
|
||||
|
||||
#[component]
|
||||
fn SceneTree<'a>(cx: Scope, selected_entity: &'a UseStateSend<Option<Entity>>) -> Element {
|
||||
fn SceneTree<'a>(cx: Scope, selected_entity: &'a UseStateSendable<Option<Entity>>) -> Element {
|
||||
let entities = use_query_filtered::<(Entity, DebugName), Without<Node>>(cx);
|
||||
let entities = entities.query();
|
||||
let mut entities = entities.into_iter().collect::<Vec<_>>();
|
||||
|
@ -97,7 +97,10 @@ fn SceneTree<'a>(cx: Scope, selected_entity: &'a UseStateSend<Option<Entity>>) -
|
|||
}
|
||||
|
||||
#[component]
|
||||
fn EntityInspector<'a>(cx: Scope, selected_entity: &'a UseStateSend<Option<Entity>>) -> Element {
|
||||
fn EntityInspector<'a>(
|
||||
cx: Scope,
|
||||
selected_entity: &'a UseStateSendable<Option<Entity>>,
|
||||
) -> Element {
|
||||
let world = use_world(cx);
|
||||
let type_registry = use_resource::<AppTypeRegistry>(cx).read();
|
||||
let components = selected_entity
|
||||
|
|
|
@ -9,7 +9,7 @@ mod events;
|
|||
mod hot_reload;
|
||||
mod parse_attributes;
|
||||
mod tick;
|
||||
mod use_state_send;
|
||||
mod use_state_sendable;
|
||||
|
||||
use self::{
|
||||
apply_mutations::BevyTemplate,
|
||||
|
@ -33,7 +33,7 @@ pub mod prelude {
|
|||
use_event_reader, use_query, use_query_filtered, use_resource, use_world,
|
||||
};
|
||||
pub use super::elements::*;
|
||||
pub use super::use_state_send::*;
|
||||
pub use super::use_state_sendable::*;
|
||||
pub use super::{DioxusUiBundle, DioxusUiPlugin, DioxusUiRoot};
|
||||
pub use bevy_mod_picking::pointer::PointerButton;
|
||||
pub use dioxus;
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
use dioxus::prelude::ScopeState;
|
||||
use std::sync::{Arc, RwLock, RwLockReadGuard};
|
||||
|
||||
pub fn use_state_send<T: Send + Sync + 'static>(
|
||||
pub fn use_state_sendable<T: Send + Sync + 'static>(
|
||||
cx: &ScopeState,
|
||||
init_rw: impl FnOnce() -> T,
|
||||
) -> &mut UseStateSend<T> {
|
||||
let hook = cx.use_hook(|| UseStateSend {
|
||||
) -> &mut UseStateSendable<T> {
|
||||
let hook = cx.use_hook(|| UseStateSendable {
|
||||
update: cx.schedule_update(),
|
||||
value: Arc::new(RwLock::new(init_rw())),
|
||||
});
|
||||
|
@ -15,12 +15,12 @@ pub fn use_state_send<T: Send + Sync + 'static>(
|
|||
hook
|
||||
}
|
||||
|
||||
pub struct UseStateSend<T> {
|
||||
pub struct UseStateSendable<T> {
|
||||
update: Arc<dyn Fn() + Send + Sync + 'static>,
|
||||
value: Arc<RwLock<T>>,
|
||||
}
|
||||
|
||||
impl<T> Clone for UseStateSend<T> {
|
||||
impl<T> Clone for UseStateSendable<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
update: self.update.clone(),
|
||||
|
@ -29,7 +29,7 @@ impl<T> Clone for UseStateSend<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> UseStateSend<T> {
|
||||
impl<T> UseStateSendable<T> {
|
||||
pub fn read(&self) -> RwLockReadGuard<'_, T> {
|
||||
self.value.read().expect("Lock poisoned")
|
||||
}
|
Loading…
Reference in a new issue