pub struct Effect<Action: Send + 'static> {
pub value: EffectValue<Action>,
}
Fields§
§value: EffectValue<Action>
Implementations§
Source§impl<Action> Effect<Action>where
Action: Send + 'static,
impl<Action> Effect<Action>where
Action: Send + 'static,
pub fn map<F, MappedAction>(self, map: F) -> Effect<MappedAction>
Sourcepub fn run<T, Fut>(job: T) -> Self
pub fn run<T, Fut>(job: T) -> Self
Wraps an asynchronous unit of work that can emit actions any number of times in an effect.
For example, if you had an async stream in a dependency client:
struct EventsClient<F: Fn() -> Stream<Item = Event> {
events: F,
}
Then you could attach to it in a run
effect and sending each action of
the stream back into the system:
match action {
Action::StartButtonTapped => {
Effect::run(async move |send| {
let events_client = EventsClient::new().events();
while let Some(event) = events_client.next().await {
send.send(Action::Event(event));
}
})
}
}
Sourcepub fn none() -> Self
pub fn none() -> Self
An effect that does nothing and completes immediately. Useful for situations where you must return an effect, but you don’t need to do anything.
Auto Trait Implementations§
impl<Action> Freeze for Effect<Action>where
Action: Freeze,
impl<Action> !RefUnwindSafe for Effect<Action>
impl<Action> Send for Effect<Action>
impl<Action> !Sync for Effect<Action>
impl<Action> Unpin for Effect<Action>where
Action: Unpin,
impl<Action> !UnwindSafe for Effect<Action>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more