🔥 Refactor TypeId/Any use, drop own Handle
This commit is contained in:
parent
8402b7946e
commit
169e562488
59 changed files with 137 additions and 289 deletions
|
|
@ -1,19 +1,17 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::FnActionComponent;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct AfterPrepareComponent<C: ComponentTrait> {
|
||||
f: FnActionComponent<C>,
|
||||
referer_handle: Option<Handle>,
|
||||
referer_type_id: Option<TypeId>,
|
||||
referer_id: OptionId,
|
||||
weight: Weight,
|
||||
}
|
||||
|
||||
impl<C: ComponentTrait> ActionTrait for AfterPrepareComponent<C> {
|
||||
fn referer_handle(&self) -> Option<Handle> {
|
||||
self.referer_handle
|
||||
fn referer_type_id(&self) -> Option<TypeId> {
|
||||
self.referer_type_id
|
||||
}
|
||||
|
||||
fn referer_id(&self) -> Option<String> {
|
||||
|
|
@ -29,7 +27,7 @@ impl<C: ComponentTrait> AfterPrepareComponent<C> {
|
|||
pub fn new(f: FnActionComponent<C>) -> Self {
|
||||
AfterPrepareComponent {
|
||||
f,
|
||||
referer_handle: Some(C::static_handle()),
|
||||
referer_type_id: Some(TypeId::of::<C>()),
|
||||
referer_id: OptionId::default(),
|
||||
weight: 0,
|
||||
}
|
||||
|
|
@ -48,7 +46,7 @@ impl<C: ComponentTrait> AfterPrepareComponent<C> {
|
|||
#[inline(always)]
|
||||
pub(crate) fn dispatch(component: &mut C, cx: &mut Context, referer_id: Option<String>) {
|
||||
dispatch_actions(
|
||||
(Self::static_handle(), Some(component.handle()), referer_id),
|
||||
(TypeId::of::<Self>(), Some(TypeId::of::<C>()), referer_id),
|
||||
|action| (action_ref::<AfterPrepareComponent<C>>(&**action).f)(component, cx),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::FnActionComponent;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct BeforePrepareComponent<C: ComponentTrait> {
|
||||
f: FnActionComponent<C>,
|
||||
referer_handle: Option<Handle>,
|
||||
referer_type_id: Option<TypeId>,
|
||||
referer_id: OptionId,
|
||||
weight: Weight,
|
||||
}
|
||||
|
||||
impl<C: ComponentTrait> ActionTrait for BeforePrepareComponent<C> {
|
||||
fn referer_handle(&self) -> Option<Handle> {
|
||||
self.referer_handle
|
||||
fn referer_type_id(&self) -> Option<TypeId> {
|
||||
self.referer_type_id
|
||||
}
|
||||
|
||||
fn referer_id(&self) -> Option<String> {
|
||||
|
|
@ -29,7 +27,7 @@ impl<C: ComponentTrait> BeforePrepareComponent<C> {
|
|||
pub fn new(f: FnActionComponent<C>) -> Self {
|
||||
BeforePrepareComponent {
|
||||
f,
|
||||
referer_handle: Some(C::static_handle()),
|
||||
referer_type_id: Some(TypeId::of::<C>()),
|
||||
referer_id: OptionId::default(),
|
||||
weight: 0,
|
||||
}
|
||||
|
|
@ -48,7 +46,7 @@ impl<C: ComponentTrait> BeforePrepareComponent<C> {
|
|||
#[inline(always)]
|
||||
pub(crate) fn dispatch(component: &mut C, cx: &mut Context, referer_id: Option<String>) {
|
||||
dispatch_actions(
|
||||
(Self::static_handle(), Some(component.handle()), referer_id),
|
||||
(TypeId::of::<Self>(), Some(TypeId::of::<C>()), referer_id),
|
||||
|action| (action_ref::<BeforePrepareComponent<C>>(&**action).f)(component, cx),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::FnActionPage;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct AfterPrepareBody {
|
||||
f: FnActionPage,
|
||||
weight: Weight,
|
||||
|
|
@ -27,7 +25,7 @@ impl AfterPrepareBody {
|
|||
|
||||
#[inline(always)]
|
||||
pub(crate) fn dispatch(page: &mut Page) {
|
||||
dispatch_actions((Self::static_handle(), None, None), |action| {
|
||||
dispatch_actions((TypeId::of::<Self>(), None, None), |action| {
|
||||
(action_ref::<AfterPrepareBody>(&**action).f)(page)
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::FnActionPage;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct BeforePrepareBody {
|
||||
f: FnActionPage,
|
||||
weight: Weight,
|
||||
|
|
@ -27,7 +25,7 @@ impl BeforePrepareBody {
|
|||
|
||||
#[inline(always)]
|
||||
pub(crate) fn dispatch(page: &mut Page) {
|
||||
dispatch_actions((Self::static_handle(), None, None), |action| {
|
||||
dispatch_actions((TypeId::of::<Self>(), None, None), |action| {
|
||||
(action_ref::<BeforePrepareBody>(&**action).f)(page)
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue