You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a balance adapter that has 10 elements and a market adapter that has many more (let's say 100). Now I want to create derived data that gets the fiat balance by multiplying my balance adapter by its USD market.
// Typing on phone so might get syntax wrongconstselectBalaceCurrencies=balanceAdapter.getAll()// returns ['USD', 'EUR']constselectBalaceByCode=balanceAdapter.getEntityById()// returns {code: 'USD', available: 10 }constselectPriceByCode=priceAdapter.getEntityById()// Returns { askPrice, dailyChange, ...ext }// What I want to do isconstselectLiveBalance=(state: RootState)=>{constcurrencies=selectCurrencies(state)constliveBalance=currencies.map((code)=>{constbalance=selectBalaceByCode(state,code)constprice=selectPriceByCode(state,code)returnbalance.available*price.askPrice}}
I have managed to merge the second two into one selector that's caching properly selectLiveBalanceByCode but I can't for the life of me work out how to get that to merge with the first selector and only update when one of the selected codes change not when any state changes or I could do it when any reference to price changes (by selecting the object adapter.getEntityRecord() //the one that returns an object but then my balance updates when a market price changes for something that we don't have a balance for.
Goal
I want to only update my derived balance when the selectPriceByCode (merged with balance it's selectLiveBalanceByCode) updates with values from selectBalanceCurrencies
I have given up for the day but can't stop thinking about it (hence typing this on phone instead of at desk)
Hope their is a solution and I have provided enough details
The text was updated successfully, but these errors were encountered:
I have been forced to use this package as I could not find a solution. Luckily it works well! Unfortunately it has not had a commit in 6 years. https://github.com/taskworld/rereselect
Background
I have a balance adapter that has 10 elements and a market adapter that has many more (let's say 100). Now I want to create derived data that gets the fiat balance by multiplying my balance adapter by its USD market.
I have managed to merge the second two into one selector that's caching properly
selectLiveBalanceByCode
but I can't for the life of me work out how to get that to merge with the first selector and only update when one of the selected codes change not when any state changes or I could do it when any reference to price changes (by selecting the objectadapter.getEntityRecord() //the one that returns an object
but then my balance updates when a market price changes for something that we don't have a balance for.Goal
I want to only update my derived balance when the selectPriceByCode (merged with balance it's
selectLiveBalanceByCode
) updates with values from selectBalanceCurrenciesI have given up for the day but can't stop thinking about it (hence typing this on phone instead of at desk)
Hope their is a solution and I have provided enough details
The text was updated successfully, but these errors were encountered: