Hey DAML’ers.
I have a question on useStreamQueries
, particularly when using multiple queries in the query factory.
The docs for the @daml/react
bindings here say that
The factory function is expected to return a list of queries, and the resulting set of contracts is the union of all the contracts that match at least one query.
My current dilemma looks something like this:
const dvpPending = useStreamQueries(DvpNotification, () => [{c:{dvpId:dvpId}}, {status:"pending"}], []);
const dvpFinalized = useStreamQueries(DvpNotification, () => [{c:{dvpId:dvpId}}, {status:"Finalized"}], []);
I then have a conditional switch statement to return different views based on whether the dvp
by the unique dvpId
is pending or has been finalized.
Since only 1 query has to return true for the contract to be retrieved, I can’t distinguish between the two as is currently written (dvpPending
and dvpFinalized
).
Is it possible to return nothing if both conditions in the query factory are not met?