Assume that the result of a query would be 50 elements long.
If you use that query in useStreamQuery and leverage that output in a component, you are going to get 50 (51?) redraws of that component, as the result will be [] then [elem1] , then [elem1, elem2] , …, then [elem1, ..., elem50] and so on.
Is the above correct? (our investigations seem to indicate that, but I’d still rather double-check)
Is the example above expected behavior?
If so, why?
My expectation would be that after calling useStreamQuery I would
Your investigation is almost correct. The ACS at the beginning of a stream query is delivered as a stream of CreateEvent arrays. We don’t make any guarantees on those arrays being singletons. I believe atm you get one per transaction so if your contracts got created as part of separate transactions you’ll see the behavior you describe. If some are part of the same transaction, you might see multiple contracts being added as part of one change.
useStreamQuery provides a loading field on the result in addition to the contracts field. This is true until the ACS query has completed and we are working with full ACS snapshots. If you don’t want to draw partial results, you can wait until loading is false before you display anything in your render function. However, it is often nicer to start with partial results and update them as you receive more.