Closed adairrr closed 2 years ago
This change gives the user the ability to request the use of a "Query Factory" that can be used for (examples using cw20):
useQueries
export const useCw20BalancesQueries = ({ account, inputs, cw20AddressAccessor, options, } => { const { readOnlyClient } = useReadonlyClients() const queries = useQueries({ queries: inputs.map((cw20) => cw20Queries.balance({ client: readOnlyClient ? new Cw20QueryClient(readOnlyClient, cw20AddressAccessor(cw20)) : undefined, args: { address: account }, options: { ...QueryOptions.DISABLE_WITHOUT(readOnlyClient, options?.enabled) }, }) ), }) return useQueries(queries) }
prefetchQuery
const queryClient = useQueryClient()
queryClient.prefetchQuery( cw20Queries.balance({ client: cw20Client, args: { address: 'terra1' }, }) )
woah this is amazing!
Quick Q: is there any new options we should add to the READMEs?
Yeah you're right! Just added the new queryFactory to the readme.
queryFactory
merged!!!! @adairrr your work is amazing thank you ⚛️
This change gives the user the ability to request the use of a "Query Factory" that can be used for (examples using cw20):
useQueries
prefetchQuery
(to be placed in cache):queryClient.prefetchQuery( cw20Queries.balance({ client: cw20Client, args: { address: 'terra1' }, }) )