Re-frame query: Declarative data fetching & caching for re-frame 0.8.0 is now live 🚀
re-frame-query is now used in production at https://www.teamohana.com/ for queries and infinite scroll, and is included in https://shipclojure.com/ for easier query setup. Feedback so far has been great.
The big theme since v0.1.0 has been moving toward making event triggers + passive subs first-class alongside the original causal ::rfq/query sub — I've found this much more testable and enjoyable to use. Who would've thought using idiomatic re-frame was better 😄
Notable changes:
- Passive subscriptions (`rfq/query-state`, ::rfq/query-data, ::rfq/infinite-query-state, ::rfq/infinite-query-data) — pure reads, no fetch side effects. Pair with explicit ::rfq/ensure-query + ::rfq/mark-active for full control.
- Event-based polling — start/stop polling via mark-active / mark-inactive opts, no causal sub required. Polling now skips ticks when a request is in-flight (`:polling-mode :force` opts out).
- `re-frame.query.db` — pure db → db cache functions (`get-query`, set-query-data, garbage-collect, ...) you can call inline from your own event handlers. Previously this was only possible through exposed rf events and this way, you skip an event dispatch loop.
- Mutation lifecycle hooks — :on-start, :on-success, :on-failure opts on execute-mutation for optimistic updates and rollback.
- Query lifecycle observability — global interceptors on ::rfq/query-success / query-failure / infinite-page-success / infinite-page-failure + the new rfq/parse-result-event helper for safe event data extraction.
- Bidirectional infinite queries — fetch-previous-page for chat/feed UIs with :max-pages sliding window in both directions.
- Tag invalidation now correctly refetches only matching queries (previously refetched all active — N×M problem).
- Both example apps demonstrate route-scoped lifecycle, polling tied to navigation, and optimistic updates.
GitHub: https://github.com/shipclojure/re-frame-query
Full changelog: https://github.com/shipclojure/re-frame-query/blob/main/CHANGELOG.md