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

allow passing parameters to custom panels #6

Open
ikitommi opened this issue Apr 11, 2022 · 4 comments
Open

allow passing parameters to custom panels #6

ikitommi opened this issue Apr 11, 2022 · 4 comments

Comments

@ikitommi
Copy link
Member

currently the panel-functions are 0-arity. To write reusable panels, there should be a way to pass parameters to them. Few suggestions:

1) pass the start! options to panels

(defn permissions-view [{:keys [permissions]}]
  ...)

(dev-tools/start!
 {:state-atom re-frame.db/app-db
  :permissions #{:a :b}
  :panels-fn {:permissions {:label "Permissions" :fn permissions-view}}})

2) like 1, but just one key, e.g. :data

(dev-tools/start!
 {:state-atom re-frame.db/app-db
  :data {:permissions #{:a :b}}
  :panels-fn {:permissions {:label "Permissions" :fn permissions-view}}})

3) something else

@Deraen
Copy link
Member

Deraen commented Apr 12, 2022

partial?

@ikitommi
Copy link
Member Author

ikitommi commented Apr 12, 2022

out of these, I would prefer 3, then 4, both 2 & 1 seem hacks to me.

1) partial

(dev-tools/start!
 {:state-atom re-frame.db/app-db
  :panels-fn {:permissions {:label "Permissions" :fn (partial permissions-view {:permissions #{:a :b}})}}})

2) reuse whole panel submap

(dev-tools/start!
 {:state-atom re-frame.db/app-db
  :panels-fn {:permissions (permissions-panel-info {:permissions #{:a :b}})}}})

3) support reagent syntax

(dev-tools/start!
 {:state-atom re-frame.db/app-db
  :panels-fn {:permissions {:label "Permissions" :fn [permission-view {:permissions #{:a :b}}]}}})

;; rename keys
(dev-tools/start!
 {:state-atom re-frame.db/app-db
  :panels {:permissions {:label "Permissions" :view [permission-view {:permissions #{:a :b}}]}}})

4) single options map

(dev-tools/start!
 {:state-atom re-frame.db/app-db
  :data {:permissions #{:a :b}}
  :panels-fn {:permissions {:label "Permissions" :fn permissions-view}}})

@Deraen
Copy link
Member

Deraen commented Apr 12, 2022

  1. seems fine. Maybe keeping :fn as is, and adding :view.

@Deraen
Copy link
Member

Deraen commented Apr 13, 2022

I wonder if I had some reason why the option is panels-fn now, and the value must a function...

Might be related to the preload namespace, where the options need to be declared on compiler options.

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