Earlier this year, I started building Gallry, an app for independent artists and for people who want a better way to discover them.
After finally reaching the point where I could say “this is enough for an MVP” (which turned out to be a surprisingly difficult line to draw, not gonna lie), I’m now preparing it for a closed beta, and before adding more features, I’ve been doing some cleanup and hardening.
One small problem that came up was remote feature flags: I wanted Gallry to pick up flag changes when the app returns from the background, without requiring a restart.
On the web, TanStack Query can react to window focus. In React Native, there is no browser window to observe, so you need to connect React Native’s AppState to React Query’s focusManager, but the more interesting question was: should returning to the foreground always trigger a database call?
Imagine this very normal mobile user flow:
*Gallry → WhatsApp → Gallry → Telegram → Gallry.
*
Those are multiple foreground events in a few minutes. Technically, I can refetch the feature flags every time, but that doesn’t mean I should.
For now, Gallry uses AppState + focusManager, while **staleTime **determines whether the query is actually stale enough to refetch. I’m also deliberately not using realtime subscriptions for feature flags yet.
What I liked about this problem is that staleTime stopped feeling like just a React Query performance setting and became a product and architecture decision: "How stale am I willing to let this feature flag become?"
For a kill switch, the answer might be “almost not at all”, but for a small UI flag, a few minutes may be perfectly fine.
Top comments (0)