Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 1.06 KB

File metadata and controls

24 lines (20 loc) · 1.06 KB

Conditional Fetching (Skip)

Use :skip? true in the subscription payload 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 {:query :user/current}])
        user-id          (:id data)
        {:keys [status]} @(rf/subscribe [::rfq/query {:query  :user/todos
                                                      :params {: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:

  • No fetch is triggered
  • The query is not marked active
  • Polling does not start (even if :polling-interval-ms is set)
  • The subscription returns {: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.