fcl-js icon indicating copy to clipboard operation
fcl-js copied to clipboard

[FEATURE] Add event-driven refecting to `useFlowQuery`

Open jribbink opened this issue 9 months ago • 2 comments

Issue to be solved

Currently, useFlowQuery is naiive to any state changes on chain that may have affected the query result and can only refetch when manually triggered by developers or within the boundaries of React Query.

It would be extremely useful to have the ability to update UI state in response to on-chain events.

Suggest A Solution

Something along the lines of:

useFlowQuery({
   ...stuff,
   refectchEvents: [
        {
            event: "A.1234.SomethingHappened"
            filter: (evt) => evt.data.user === "FooBar"
         }
    ]
})

What are you currently working on that this is blocking?

No response

jribbink avatar May 21 '25 22:05 jribbink

@bluesign I'd be curious if you had any thoughts/other ideas around this.

I'm trying to think of ways that we can make apps more responsive and lean into event streaming better (which feels woefully underutlized right now).

jribbink avatar May 21 '25 22:05 jribbink

@jribbink oh I was playing with this idea a little bit; ( at least similar )

I think account address(es) as dependency works here better than events. ( Event is tricky because naive approach there always leads to over subscribing, as a developer my instinct can be to subscribe to FlowToken / FungibleToken events if I have a label with user's flow balance etc ). Also on another level, even on correct usage, events feel like something still simulated when no-one is looking.

bluesign avatar May 22 '25 07:05 bluesign