This repository was archived by the owner on Aug 9, 2024. It is now read-only.

Description
Case
Sometimes you need to gather data from multiple KVs based on one
Basically like JOIN from SQL
Solution
export const $txWidget = grabItems(Widget.model.$kv, {
source: {
deposit: Deposit.model.$kv,
withdraw: Withdraw.model.$kv,
earn: Earn.model.$kv,
},
filter: {
deposit: (deposit, widget) => widget.txHashes.includes(deposit.tx_hash),
withdraw: (deposit, widget) => widget.txHashes.includes(deposit.tx_hash),
earn:(deposit, widget) => widget.txHashes.includes(deposit.tx_hash),
},
orderBy: (a, b, widgetState) => a.value.timestamp - b.value.timestamp
})
Returned store will have the following shape:
{
[wigetId]: {
item: Widget,
children: {
type: 'deposit' | 'withdraw' | 'earn',
value: Deposit | Withdraw | Earn
}[]
}
}