Skip to content
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

Callback event should also be given all the input arguments #89

Open
oliyh opened this issue Jun 28, 2022 · 1 comment
Open

Callback event should also be given all the input arguments #89

oliyh opened this issue Jun 28, 2022 · 1 comment

Comments

@oliyh
Copy link
Owner

oliyh commented Jun 28, 2022

It's now given a map with :response key populated, but it might be nice if it also had :id, :query, :variables etc as well, this could potentially save the user piping this stuff around if they need it in the callback handler

@toniz4
Copy link

toniz4 commented Jan 5, 2024

Even better, It would be nice if it was able to add any arguments to the callback. Kinda like currying the event

(re-frame/reg-event-db
  ::on-thing
  [re-frame/unwrap]
  (fn [db [user-id user {:keys [response]}]]
    (let [{:keys [data errors]} response]
      ;; do things with data e.g. write it into the re-frame database
    )))


(re-frame/dispatch [::re-graph/subscribe
                    {:id        :my-subscription-id
                     :query     "{ things { id } }"
                     :variables {:some "variable"}
                     :callback  [::on-thing 10 {:username "user" :role "admin"}]}])

What do you think? This would unfortunately break the current functionality, but I think it's a nice addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants