pub struct Effects<MSG, XMSG> {
pub local: Vec<MSG, Global>,
pub external: Vec<XMSG, Global>,
/* private fields */
}
Expand description
Effects is a convenient way to group Msg for component to execute subsequent updates based on certain conditions. This can be used for doing animation and incremental changes to the view to provide an effect of transition or animation.
Effects contains 2 types of Messages. The local messages which will be executed in its own component on the next update loop. The other type is the external effects which are Messages that are sent to the parent Component in response to an event that has been triggerred.
Fields
local: Vec<MSG, Global>
Messages that will be executed locally in the Component
external: Vec<XMSG, Global>
effects that will be executed on the parent Component that instantiate this component
Implementations
sourceimpl<MSG, XMSG> Effects<MSG, XMSG>
impl<MSG, XMSG> Effects<MSG, XMSG>
sourcepub fn new(
local: impl IntoIterator<Item = MSG>,
external: impl IntoIterator<Item = XMSG>
) -> Effects<MSG, XMSG>
pub fn new(
local: impl IntoIterator<Item = MSG>,
external: impl IntoIterator<Item = XMSG>
) -> Effects<MSG, XMSG>
create a new Effects with local and external expects respectively
sourcepub fn unzip(self) -> (Vec<MSG, Global>, Vec<XMSG, Global>)
pub fn unzip(self) -> (Vec<MSG, Global>, Vec<XMSG, Global>)
split the local and external MSG of this effect
sourcepub fn with_local(local: impl IntoIterator<Item = MSG>) -> Effects<MSG, XMSG>
pub fn with_local(local: impl IntoIterator<Item = MSG>) -> Effects<MSG, XMSG>
Create an Effects with local messages that will be executed on the next update loop on this Component
sourcepub fn with_external(
external: impl IntoIterator<Item = XMSG>
) -> Effects<MSG, XMSG>
pub fn with_external(
external: impl IntoIterator<Item = XMSG>
) -> Effects<MSG, XMSG>
Create an Effects with extern messages that will be executed on the parent Component
sourcepub fn map_msg<F, MSG2>(self, f: F) -> Effects<MSG2, XMSG> where
F: 'static + Fn(MSG) -> MSG2,
pub fn map_msg<F, MSG2>(self, f: F) -> Effects<MSG2, XMSG> where
F: 'static + Fn(MSG) -> MSG2,
Map the local messages of this Effects such that MSG will be transposed into
MSG2 with the use of the mapping function f
.
The external messages stays the same.
sourcepub fn localize<F>(self, f: F) -> Effects<XMSG, ()> where
F: 'static + Fn(MSG) -> XMSG,
pub fn localize<F>(self, f: F) -> Effects<XMSG, ()> where
F: 'static + Fn(MSG) -> XMSG,
derives an Effects which contains only local effects by transforming the external messages
and mapping them with function f
such that they can be of the same type as local effects
them merge them together into local effects.
sourcepub fn append_local(
self,
local: impl IntoIterator<Item = MSG>
) -> Effects<MSG, XMSG>
pub fn append_local(
self,
local: impl IntoIterator<Item = MSG>
) -> Effects<MSG, XMSG>
Append this msgs to the local effects
sourcepub fn no_render(self) -> Effects<MSG, XMSG>
pub fn no_render(self) -> Effects<MSG, XMSG>
Modify the Effect such that it will not do an update on the view when it is executed
sourcepub fn measure(self) -> Effects<MSG, XMSG>
pub fn measure(self) -> Effects<MSG, XMSG>
Modify the Effect such that it will log measurement when it is executed
sourcepub fn merge_all(
all_effects: Vec<Effects<MSG, XMSG>, Global>
) -> Effects<MSG, XMSG>
pub fn merge_all(
all_effects: Vec<Effects<MSG, XMSG>, Global>
) -> Effects<MSG, XMSG>
Merge all the internal objects of this Vec of Effects to produce only one.
sourcepub fn extend(
self,
local: impl IntoIterator<Item = MSG>,
external: impl IntoIterator<Item = XMSG>
) -> Effects<MSG, XMSG>
pub fn extend(
self,
local: impl IntoIterator<Item = MSG>,
external: impl IntoIterator<Item = XMSG>
) -> Effects<MSG, XMSG>
Extern the local and external MSG of this Effect
Trait Implementations
Auto Trait Implementations
impl<MSG, XMSG> RefUnwindSafe for Effects<MSG, XMSG> where
MSG: RefUnwindSafe,
XMSG: RefUnwindSafe,
impl<MSG, XMSG> Send for Effects<MSG, XMSG> where
MSG: Send,
XMSG: Send,
impl<MSG, XMSG> Sync for Effects<MSG, XMSG> where
MSG: Sync,
XMSG: Sync,
impl<MSG, XMSG> Unpin for Effects<MSG, XMSG> where
MSG: Unpin,
XMSG: Unpin,
impl<MSG, XMSG> UnwindSafe for Effects<MSG, XMSG> where
MSG: UnwindSafe,
XMSG: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more