fixed registers
This commit is contained in:
parent
0e33a09d8f
commit
76e95f2859
@ -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
|
||||
.entry(state)
|
||||
.or_default()
|
||||
.push(Box::new(move |pw, s| tokio::spawn(f(&pw, s))));
|
||||
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(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ pub enum PositionState {
|
||||
BreakEven,
|
||||
MinimumProfit,
|
||||
Profit,
|
||||
Any,
|
||||
}
|
||||
|
||||
impl PositionState {
|
||||
|
Loading…
Reference in New Issue
Block a user