pub fn persist_event_if<B, F, R>(f: F) -> ThenPersistEvent<B, F, R>where
    B: EventSourcedBehavior + Send + Sync + 'static,
    B::State: Send + Sync,
    F: FnOnce(&B, Option<&B::State>, Result) -> R + Send,
    R: Future<Output = Result<Option<B::Event>, Error>> + Send,
    <B as EventSourcedBehavior>::Event: Send,
Expand description

A side effect to run a function asynchronously and then, if ok, persist an event. The associated behavior is available so that communication channels, for example, can be accessed by the side-effect. Additionally, the latest state given any previous effect having persisted an event, or else the state at the outset of the effects being applied, is also available.