pub struct Effects<MSG, XMSG> {
pub local: Vec<Task<MSG>, Global>,
pub external: Vec<Task<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<Task<MSG>, Global>
Messages that will be executed locally in the Component
external: Vec<Task<XMSG>, Global>
effects that will be executed on the parent Component which instantiate this component
Implementations§
source§impl<MSG, XMSG> Effects<MSG, XMSG>where
MSG: 'static,
impl<MSG, XMSG> Effects<MSG, XMSG>where MSG: 'static,
sourcepub fn new(
local: impl IntoIterator<Item = MSG>,
external: impl IntoIterator<Item = XMSG>
) -> Effects<MSG, XMSG>where
XMSG: 'static,
pub fn new( local: impl IntoIterator<Item = MSG>, external: impl IntoIterator<Item = XMSG> ) -> Effects<MSG, XMSG>where XMSG: 'static,
create a new Effects with local and external expects respectively
sourcepub fn with_async<F, FX>(
local: impl IntoIterator<Item = F>,
external: impl IntoIterator<Item = FX>
) -> Effects<MSG, XMSG>where
F: Future<Output = MSG> + 'static,
FX: Future<Output = XMSG> + 'static,
XMSG: 'static,
pub fn with_async<F, FX>( local: impl IntoIterator<Item = F>, external: impl IntoIterator<Item = FX> ) -> Effects<MSG, XMSG>where F: Future<Output = MSG> + 'static, FX: Future<Output = XMSG> + 'static, XMSG: 'static,
Create a new Effects with local and external futures that can resolve to MSG and XMSG respectively
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_local_async<F>(
local: impl IntoIterator<Item = F>
) -> Effects<MSG, XMSG>where
F: Future<Output = MSG> + 'static,
pub fn with_local_async<F>( local: impl IntoIterator<Item = F> ) -> Effects<MSG, XMSG>where F: Future<Output = MSG> + 'static,
Create an Effects with local message that will can resolved into MSG, it will be executed on the next update loop on the component it is being returned
sourcepub fn with_external(
external: impl IntoIterator<Item = XMSG>
) -> Effects<MSG, XMSG>where
XMSG: 'static,
pub fn with_external( external: impl IntoIterator<Item = XMSG> ) -> Effects<MSG, XMSG>where XMSG: 'static,
Create an Effects with extern messages that will be executed on the parent Component
sourcepub fn with_external_async<F>(
external: impl IntoIterator<Item = F>
) -> Effects<MSG, XMSG>where
F: Future<Output = XMSG> + 'static,
XMSG: 'static,
pub fn with_external_async<F>( external: impl IntoIterator<Item = F> ) -> Effects<MSG, XMSG>where F: Future<Output = XMSG> + 'static, XMSG: 'static,
Create an Effects with external messages that will can be resolved into an XMSG, this will be dispatch in the next Component update
sourcepub fn map_msg<F, MSG2>(self, f: F) -> Effects<MSG2, XMSG>where
F: Fn(MSG) -> MSG2 + Clone + 'static,
MSG2: 'static,
pub fn map_msg<F, MSG2>(self, f: F) -> Effects<MSG2, XMSG>where F: Fn(MSG) -> MSG2 + Clone + 'static, MSG2: 'static,
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 map_external<F, XMSG2>(self, f: F) -> Effects<MSG, XMSG2>where
F: Fn(XMSG) -> XMSG2 + Clone + 'static,
XMSG: 'static,
XMSG2: 'static,
pub fn map_external<F, XMSG2>(self, f: F) -> Effects<MSG, XMSG2>where F: Fn(XMSG) -> XMSG2 + Clone + 'static, XMSG: 'static, XMSG2: 'static,
Map the external messages of this Effects such that XMSG will be transposed into XMSG2
with the use of the mapping function f
sourcepub fn localize<F, XMSG2>(self, f: F) -> Effects<XMSG, XMSG2>where
F: Fn(MSG) -> XMSG + Clone + 'static,
XMSG: 'static,
XMSG2: 'static,
pub fn localize<F, XMSG2>(self, f: F) -> Effects<XMSG, XMSG2>where F: Fn(MSG) -> XMSG + Clone + 'static, XMSG: 'static, XMSG2: 'static,
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 measure_with_name(self, name: &str) -> Effects<MSG, XMSG>
pub fn measure_with_name(self, name: &str) -> Effects<MSG, XMSG>
Modify the Effect such that it will log measurement tag with the name supplied
sourcepub fn batch(
all_effects: impl IntoIterator<Item = Effects<MSG, XMSG>>
) -> Effects<MSG, XMSG>
pub fn batch( all_effects: impl IntoIterator<Item = Effects<MSG, XMSG>> ) -> 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>where
XMSG: 'static,
pub fn extend( self, local: impl IntoIterator<Item = MSG>, external: impl IntoIterator<Item = XMSG> ) -> Effects<MSG, XMSG>where XMSG: 'static,
Extern the local and external MSG of this Effect