-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Subscribe to the offline queue? #57
Comments
hi @isocra,
Let me know if this is what you were looking for and I will leave this issue open as a reminder to improve the documentation |
Yes thanks, that's what I needed. Here's my implementation in case it's useful to anyone else. const [outboxCount, setOutboxCount] = useState<number>(0);
const client = useApolloClient() as ApolloClient; // import { ApolloClient } from '@wora/apollo-offline';
useEffect(() => {
const dispose = client.getStoreOffline().subscribe((state, action) => {
setOutboxCount(state.length);
});
return () => {
dispose(); // Make sure we unsubscribe when we're unmounted
};
}); I then use Thanks for your super-quick support! |
Hi @morrys, I'm trying a similar thing to @isocra, but rather than just showing a count I'm wanting to display all my records having pending mutations with an icon in the UI, plus offer a convenient list of the records to the user. I've looked over the internal structure of I was thinking of traversing Is there a better way for me to work out which models have changed when offline? If not, what do you think about having a public method to return this data? Thanks! |
Hi @sc0ttdav3y, is it right? |
Hi @morrys, That seems like it could work, but that TodoOffline example exposes a lot of your internal implementation into the React component. My concern on that level of coupling is that things will break if you refactor your work later on. Ideally we'd have a supported method on the offline store to get our changed data:
From there we can map and reduce our way to get our records, counts, etc. This proposed method:
Perhaps I missed something with my second point, as I'm only new to WORA and GraphQL generally, but the second point is something I think is missing in the simpler Todo examples, where things get trickier in real apps when we are dealing with multiple models with multiple mutations. I guess the proposed API is for your consideration, but that's the general idea. |
Hi @sc0ttdav3y, This allows you to use this information according to your needs both during the entire offline workflow and in the subscription to the offline queue. |
I'd like to display an icon to show if there are pending mutations while offline, I can't see any options to find out how big the queue is. Is there a way?
Thanks!
The text was updated successfully, but these errors were encountered: