fix: Pass key_fn to TableUpdate Operate ext

Bugs (fixed):
  * PNL window crashes immediately when opened

    Cause: The 'Operate' ext fn aggregates an IObservable of TableUpdates w/
    another IObservable of any T.  If the latter fires before the former, an
    'empty' TableUpdate is passed to the aggregate fn.  When this happens, a
    null ref ex is thrown in the 'empty' TableUpdate's ctr because the key
    param is null.
This commit is contained in:
John Colvin committed 2022-08-01 11:14:28 -04:00
1 parent e82a2c9402
commit 76ec2c0fa2
2 files changed
+6 -4

No files matched your search

@@ -128,8 +128,9 @@
_dispose = Disposable.Create(
position_model.security_account_pnl.Operate(
_calculation_type.observe_current(true),
(data, calc) => data.with(calc_type: calc)
).FilterWithRaw(filter_src, PNLRowData.key_fn, null)
(data, calc) => data.with(calc_type: calc),
PNLRowData.key_fn)
.FilterWithRaw(filter_src, PNLRowData.key_fn, null)
.OnDispatcher()
.Subscribe(_update),
_symbols_source(position_model.security_account_pnl).OnDispatcher().Subscribe(symbol_filter_items_observer),
@@ -500,6 +500,7 @@ namespace bts.api.core {
this IObservable<TableUpdate<T, TKey>> source,
IObservable<TParam> param_source,
Func<T, TParam, T> operate,
Func<T, TKey> key_fn,
TParam init_param = default
) where TKey : IEquatable<TKey> {
return AggregateLatest(
@@ -507,8 +508,8 @@ namespace bts.api.core {
param_source,
on_left,
on_right,
() => TableUpdate<T, TKey>.empty,
TableUpdate<T, TKey>.empty,
() => TableUpdate<T, TKey>.mk_empty(key_fn),
TableUpdate<T, TKey>.mk_empty(key_fn),
init_param);
TableUpdate<T, TKey> on_left(