-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
🏝️ TanStack Query DevTools for Expo/React Native! 🚀 #8846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4b3e884
f7b02b4
16b0e7d
10074bf
33cabd4
e7150fc
2ec65f3
cff1c33
89ffabe
874bb10
452bf71
3aba238
5cae570
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,38 @@ interface ContinueAction { | |
type: 'continue' | ||
} | ||
|
||
export interface RefetchActionEvent { | ||
type: 'ACTION-REFETCH' | ||
} | ||
|
||
export interface InvalidateActionEvent { | ||
type: 'ACTION-INVALIDATE' | ||
} | ||
|
||
export interface TriggerErrorActionEvent { | ||
type: 'ACTION-TRIGGER-ERROR' | ||
} | ||
|
||
export interface RestoreErrorActionEvent { | ||
type: 'ACTION-RESTORE-ERROR' | ||
} | ||
|
||
export interface ResetActionEvent { | ||
type: 'ACTION-RESET' | ||
} | ||
|
||
export interface RemoveActionEvent { | ||
type: 'ACTION-REMOVE' | ||
} | ||
|
||
export interface TriggerLoadingActionEvent { | ||
type: 'ACTION-TRIGGER-LOADING' | ||
} | ||
|
||
export interface RestoreLoadingActionEvent { | ||
type: 'ACTION-RESTORE-LOADING' | ||
} | ||
|
||
interface SetStateAction<TData, TError> { | ||
type: 'setState' | ||
state: Partial<QueryState<TData, TError>> | ||
|
@@ -148,6 +180,14 @@ export type Action<TData, TError> = | |
| PauseAction | ||
| SetStateAction<TData, TError> | ||
| SuccessAction<TData> | ||
| TriggerErrorActionEvent | ||
| RestoreErrorActionEvent | ||
| RefetchActionEvent | ||
| RestoreLoadingActionEvent | ||
| RemoveActionEvent | ||
| TriggerLoadingActionEvent | ||
| ResetActionEvent | ||
| InvalidateActionEvent | ||
Comment on lines
+183
to
+190
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. even though we’re not doing anything with these action in the query-core, the type is still widened, which means users will likely start to listen to these events even though they cannot be received except from the devtools.
I don’t think we’re talking about the same things till, because no changes to the query-core means the package isn’t touched, but that’s not the case right now.
the devtools now emit the events, but they emit them to the QueryCache still. The only reason they do this is, I think, because the only thing you can subscribe to is the QueryCache. I think what I wanted to get to is that you somehow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that makes much more sense. That was my original plan as well... I’m not sure why I changed it. Probably too much Red Bull these past few weeks 😅. I’ll work on that, thank you!! |
||
|
||
export interface SetStateOptions { | ||
meta?: any | ||
|
@@ -615,6 +655,8 @@ export class Query< | |
...state, | ||
...action.state, | ||
} | ||
default: | ||
return state | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think these should be here. The actions listened on the NotifyEvents are events that are dispatched from our query reducer. Consumers can listen to those to observe updates that happen in the cache. When the devtools trigger an update that will result in an internal state change, those changes will automatically be propagated.
Can you explain why those were added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any other ideas to capture action events that's reliable? I added these, so I know exactly what action is pressed to forward the action to mobile. it just seemed like the easiest approach to subscribe to query events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I don’t understand what you’re trying to do. Why do you need to capture an event that happens in the devtools? Capture it where?
Assume I understand nothing about react native and expo (which is 99% true) and try to break down for me what you’re doing. If you want to listen to events from the devtools, doing that by dispatching an event on the queryCache and then listening to that is pretty likely not the right approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My plugin includes a web view that runs the React Query DevTools. The challenge I’m facing is linking DevTools actions to another client—in this case, mobile. I need to know when actions like refetch, invalidate, or set online/offline are triggered inside the DevTools UI.
Right now, the web view listens for those actions and sends a message to the mobile client to trigger the same action there. This works for all DevTools actions and online state changes.
If there's a simpler way to detect which action was pressed—along with the associated query and action type—I’d be happy to update the approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so should we make the devtools emit those events and you’d directly listen to those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, just to be on the same page: this would mean no changes to the
query-core
, right? because those messages wouldn’t go through the query cache...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay great 👍