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

Event handler documentation #457

Open
gacelita opened this issue Mar 8, 2018 · 4 comments
Open

Event handler documentation #457

gacelita opened this issue Mar 8, 2018 · 4 comments

Comments

@gacelita
Copy link
Contributor

gacelita commented Mar 8, 2018

At the moment, re-frame does not give users a way of adding docstrings to event handlers. I open this issue to discuss this possibility. Adding specs could be useful too (I'm fond of data specs)

Quick proof of concept for adding documentation, which extends reg-event-fx (ignores interceptors though)

(defonce ^:private extended-event-handler-data (atom {}))

(defn reg-event-fx
  ([kw f]
   (rf/reg-event-fx kw f))
  ([kw options f]
   (swap! extended-event-handler-data assoc kw options)
   (rf/reg-event-fx kw f)))

(defn event-handler-doc [kw]
  (:doc (get @extended-event-handler-data kw)))

(reg-event-fx
 ::categories.list
 {:doc "Lists categories indeed"}
 (fn [_ _]
   {:dispatch ["..."]}))

;;
;;

(event-handler-doc ::categories.list)
=> "Lists categories indeed"
@mike-thompson-day8
Copy link
Contributor

Thanks. I'm working on a plan. More soon.

@ghost
Copy link

ghost commented Nov 22, 2018

Why does a string after the keyword not work here, like it does for function definitions?

@celwell
Copy link

celwell commented Aug 8, 2019

Until some kind of docstringability is added to re-frame, what would the suggested best practice be for clarifying quirky events? Comments above the reg-event-fx?

@gacelita
Copy link
Contributor Author

gacelita commented Aug 8, 2019

Until some kind of docstringability is added to re-frame, what would the suggested best practice be for clarifying quirky events? Comments above the reg-event-fx?

Either that, or extracting the complex functionality (or all the functionality) to a function, and document the function

@day8 day8 deleted a comment from LuigiBaute Jul 30, 2023
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

3 participants