Fork me on GitHub

I know I’ve asked this in the past, but can’t seem to recall. If you want a simple string to populate an input and also be a part of the URL, does it make more sense to have :on-change call secretary/dispatch, or to call a handler along the lines of :set-input-string, and for that handler to set the secretary route?


I ended up manually setting the URL, which triggers the secretary route, which dispatches reframe events, but that feels wrong to me. Any insight on how to properly set up changing URLs, re-frame events, and secretary would be appreciated.


It seems to me that, from within the input box, I would want to have a function that dispatches the fact that the string changed, but the only way I can think of is simply writing 2 of each handler (e.g. set-variable-url, set-variable-actual)


I like all mutations to go in event handlers


I agree, but is my assumption that I need essentially 2 of each handler that changes the URL to deal with that? i.e. one to set the URL, which triggers secretary, that then sets the actual data?


Or would you recommend disabling secretary hooking into the pushstate like that, and just update the URL and data in a single handler


I ended up going with this:

(defn generate-url [db]
  (let [{:keys [query-string]} db]
    (str "#/" query-string)

(defn set-url [db]
  (aset js/window "location" (generate-url db)))


 (fn [db [query-string]]
   (set-url (set-query-string db [query-string]))
Where the view code dispatches update-query-string, which triggers a URL change, which causes secretary to dispatch set-query-string