p2p/disconnection_effectful/
p2p_disconnection_effectful_effects.rs1use redux::ActionMeta;
2
3use crate::disconnection::P2pDisconnectionAction;
4
5use super::{P2pDisconnectionEffectfulAction, P2pDisconnectionService};
6
7impl P2pDisconnectionEffectfulAction {
8 pub fn effects<Store, S>(self, _: &ActionMeta, store: &mut Store)
9 where
10 Store: crate::P2pStore<S>,
11 Store::Service: P2pDisconnectionService,
12 {
13 match self {
14 P2pDisconnectionEffectfulAction::Init { peer_id } => {
15 if store.service().disconnect(peer_id) {
16 store.dispatch(P2pDisconnectionAction::Finish { peer_id });
18 }
19 }
20 }
21 }
22}