hi, is there an easy way to define a custom parser function for om.next? would have to impl a new UntangledApplication right?
@pedroteixeira untangled makes a lot of the client state decisions for you and provides an appropriate parser function so all you have to write is the mutations.
@pedroteixeira oh I see, well we bidi with app state to do url routes, our route structure looks like this
(def routes
["/"
{"beta" :beta/index
"templates" {"" :templates/index
"/"
{"" :templates/index
[[keyword :template-type] "/new"] :templates/new}}
"reports" :reports/index
"dashboards/"
{"" :dashboards/index
"new" :dashboards/new
[[id+ :id] "/"]
{"" :dashboards/show
"copy" :dashboards/copy
"edit-schedule/" :dashboards/edit-schedule}
[[id+ :id] "/edit"] :dashboards/edit}
"" [[true :dashboards/index]]}])
then we just store the keyword route value like :dashboard/new
in app state and make rendering decisions based on it
then we use pushy to do the url magic
(defn navigate [{:keys [page params replace?] :as route}]
(if history
(let [route (url->route js/location.pathname)
current-handler (:handler route)
current-params (:route-params route)
navigate* (if replace? pushy/replace-token! pushy/set-token!)]
(when (or (not= page current-handler)
(not= params current-params))
(navigate* history (route->url page params))))
(log/warn "History API not available, ignoring route request" route)))
(defn navigate-url [{:keys [url replace?]}]
(if history
(let [navigate* (if replace? pushy/replace-token! pushy/set-token!)]
(when (not= js/location.pathname url)
(navigate* history url)))
(log/warn "History API not available, ignoring route request" url)))
(defn mount [comp]
(when-not history
(let [update-fn (fn [{v :handler p :route-params :as route}]
(let [route-handler (handlers v)
{:keys [mutations post-cb]} (if route-handler
(route-handler p))
route-action `[(route/update {:page ~v :params ~p})
(modal/close)]]
(om/transact! comp (vec (concat route-action mutations
[:ui/current-route :ui/modal-open])))
(if post-cb (post-cb))))
listener (pushy/pushy update-fn url->route)]
(set! history listener))))
(defn start []
(pushy/start! history))
(defn stop []
(pushy/stop! history))
seems to work well with untangled
thanks for the examples!
Is anybody using untangled-om-css ?
In dev & simple mode works well but for advanced I get everything like <style>.#object[hW "function hW(){React_Component_apply(this,arguments);this_state=null!=this_bc?this_bc():{};return this}"]__h3
currentoor: I was trying to think of ways to implement routing, and would need ways to plugin custom read functions for some keywords (not being looked up directly in app state), not sure if this can achieved in untangled
@pedroteixeira what sort of routing? like url routing or app state routing?
@claudiu I know there are users of it.
Iโm working right now with @timovanderkamp on some improvements.
rather, he is doing them, and Iโm advising
not sure why advanced compile would be a problem.
๐ just one of those days. Probably a small mistake on my part, but canโt really seem to tack it down.
@claudiu are you using the helper function upsert-css
? Not sure if it would make a difference but you could try to emit a dom/style
element yourself.
Both methods are described in the readme of untangled/om-css