Use :skip? true in the subscription opts to prevent a query from firing. This is useful for dependent queries — where query B needs data from query A before it can fetch.
(defn user-todos []
(let [{:keys [data]} @(rf/subscribe [::rfq/query :user/current {}])
user-id (:id data)
{:keys [status]} @(rf/subscribe [::rfq/query :user/todos {:user-id user-id}
{:skip? (nil? user-id)}])]
(case status
:idle [:div "Waiting for user..."]
:loading [:div "Loading todos..."]
:success [:ul ...])))
When :skip? is true:
:polling-interval-ms is set){:status :idle :data nil :error nil :fetching? false :stale? true}When the component re-renders with :skip? false (or without the :skip? key), the query fires automatically.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |