fixed registers
This commit is contained in:
parent
0e33a09d8f
commit
76e95f2859
@ -119,10 +119,12 @@ impl EventDispatcher {
|
|||||||
F: Fn(&Event, &PairStatus) -> Fut,
|
F: Fn(&Event, &PairStatus) -> Fut,
|
||||||
Fut: Future<Output = ()> + Send,
|
Fut: Future<Output = ()> + Send,
|
||||||
{
|
{
|
||||||
self.event_handlers
|
let f = Box::new(move |e, s| tokio::spawn(f(&e, s)));
|
||||||
.entry(event)
|
|
||||||
.or_default()
|
match event {
|
||||||
.push(Box::new(move |e, s| tokio::spawn(f(&e, s))));
|
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>(
|
pub fn register_positionstate_handler<F: 'static, Fut: 'static>(
|
||||||
@ -133,9 +135,15 @@ impl EventDispatcher {
|
|||||||
F: Fn(&PositionWrapper, &PairStatus) -> Fut,
|
F: Fn(&PositionWrapper, &PairStatus) -> Fut,
|
||||||
Fut: Future<Output = ()> + Send,
|
Fut: Future<Output = ()> + Send,
|
||||||
{
|
{
|
||||||
self.position_state_handlers
|
let f = Box::new(move |pw, s| tokio::spawn(f(&pw, s)));
|
||||||
.entry(state)
|
|
||||||
.or_default()
|
match state {
|
||||||
.push(Box::new(move |pw, s| tokio::spawn(f(&pw, s))));
|
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,
|
BreakEven,
|
||||||
MinimumProfit,
|
MinimumProfit,
|
||||||
Profit,
|
Profit,
|
||||||
|
Any,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PositionState {
|
impl PositionState {
|
||||||
|
Loading…
Reference in New Issue
Block a user