fixed registers

This commit is contained in:
Giulio De Pasquale 2021-01-04 13:27:30 +00:00
parent 0e33a09d8f
commit 76e95f2859
2 changed files with 17 additions and 8 deletions

View File

@ -119,10 +119,12 @@ impl EventDispatcher {
F: Fn(&Event, &PairStatus) -> Fut,
Fut: Future<Output = ()> + Send,
{
self.event_handlers
.entry(event)
.or_default()
.push(Box::new(move |e, s| tokio::spawn(f(&e, s))));
let f = Box::new(move |e, s| tokio::spawn(f(&e, s)));
match event {
EventKind::Any => self.on_any_event_handlers.push(f),
_ => self.event_handlers.entry(event).or_default().push(f),
}
}
pub fn register_positionstate_handler<F: 'static, Fut: 'static>(
@ -133,9 +135,15 @@ impl EventDispatcher {
F: Fn(&PositionWrapper, &PairStatus) -> Fut,
Fut: Future<Output = ()> + Send,
{
self.position_state_handlers
let f = Box::new(move |pw, s| tokio::spawn(f(&pw, s)));
match state {
PositionState::Any => self.on_any_position_state_handlers.push(f),
_ => self
.position_state_handlers
.entry(state)
.or_default()
.push(Box::new(move |pw, s| tokio::spawn(f(&pw, s))));
.push(f),
}
}
}

View File

@ -7,6 +7,7 @@ pub enum PositionState {
BreakEven,
MinimumProfit,
Profit,
Any,
}
impl PositionState {