This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # arachne (1)
- # beginners (27)
- # boot (17)
- # cider (10)
- # cljs-dev (5)
- # cljsrn (76)
- # clojure (59)
- # clojure-austin (2)
- # clojure-brasil (1)
- # clojure-greece (76)
- # clojure-mexico (1)
- # clojure-quebec (63)
- # clojure-russia (16)
- # clojure-spec (127)
- # clojure-uk (12)
- # clojurescript (72)
- # community-development (7)
- # core-async (3)
- # core-matrix (2)
- # cursive (13)
- # datomic (8)
- # emacs (4)
- # funcool (4)
- # hoplon (148)
- # immutant (5)
- # keechma (2)
- # lambdaisland (5)
- # lein-figwheel (15)
- # leiningen (20)
- # off-topic (23)
- # om (13)
- # om-next (19)
- # onyx (11)
- # planck (11)
- # re-frame (59)
- # reagent (14)
- # rum (34)
- # specter (30)
- # spirituality-ethics (16)
- # uncomplicate (5)
- # untangled (387)
- # yada (2)
From your undo/redo post, seems like you’d have to do some prep work to store past versions of database because we’re using swap!’s
All the work is in the chrome extension. Getting the necessary information out of re-frame is pretty easy
I don't know if this is a re-frame-only issue, but I'll ask here, maybe someone can help me figure it out: is there any way using re-frame to route something on load?
What I mean is that if there is a url already set at the loading of the page (that would normally be routed after a url change) the main page gets loaded in any case (that is, the routing is not working until the url changes)
This is my core.cljs:
(secretary/set-config! :prefix "#") (defroute "/"  (dispatch [:view-id ""])) (defroute #".*" [id] (dispatch [:view-id id])) (def history (doto (History.) (events/listen EventType.NAVIGATE (fn [event] (secretary/dispatch! (.-token event)))) (.setEnabled true))) (dispatch-sync [:initialize-db]) (println "Starting render!") (r/render [my-ns.views/app] (.getElementById js/document "well"))
The main use case for this is to be able to use URLs to link to content into the app
@nilrecurring: The re-frame todomvc example correectly interprets the URL (on app load)
The URL encodes the selected filter control at the bottom of the page (one of all, completed, active).
Just implemented this for a firebase app https://github.com/Day8/re-frame/wiki/Subscribing-To-A-Database — now this seems to redundantly establish listeners when reloading, how do you make sure
on-dispose is called when reloading?
The thing that is driving me crazy is that it works on url change (so it's working), but not on app load
(and the id is an arbitrary string that may or may not be present in an hash-map)
@mikethompson: investigating more: I got rid of the regexp on the defroute, using destructuring now. Now it works correctly after a figwheel reload (so I load the page and the routing doesn't work, I save the file and on figwheel reload the routing works correctly)
Logging stuff into the rendering function in the views.cljs it seems that the routing kicks in before the app is ready, so I log something like this:
id: 575430df6ff9f07b8b012333 Starting render! Loading the app...
With this routing function
(defroute "/:id" [id] (do (js/console.log (str "id: " id)) (dispatch [:view-id id])))
i wanted to use datascript in a re-frame app, and the only way i could get the subscriptions to work was to populate sink the data in app-db from datascript queries in the handlers. Is the right way? Can datascript be used to hot load browser localstorage?
Anyone got an example of a subscription with multiple ratoms, I’ve heard it can be done
This ticket is about subscription definition, but let's remind ourselves about use: (subscribe [:query-id 1 2 3] [r1 r2]) The 1st parameter is the query vector, which starts with the query-id (generally a namespaced keyword). The 2nd parameter is a vector of input signals (ratoms/reactions). When they change, the subscription should be rerun. Most subscriptions only involve one parameter. Many re-framers don';t even know about the 2nd.
Before reading this, I was one of those re-framers who didn’t know about the second, I wish to no longer be
@conaw: the second parameter is for dynamic subscriptions - for passing parameters to a subscription when those parameters are already wrapped in a
reaction - here's an example subscription using the second param https://www.refheap.com/07cd87724b6bd330fc66b06e7 - you should be able to pass any
ratom like things in there
@conaw: there's a wiki page, of course 🙂 https://github.com/Day8/re-frame/wiki/Dynamic-Subscriptions
(register-sub :todo-dynamic (fn todo-dynamic [_ _ [active-list]] (let [q (q/get-query active-list)] q)))
What is a clean what to have a “subscription” or data change dispatch to handler if it detects a change. This is outside of a component.
Here is a description of what I am trying to do. The base part of the app has a search bar that can affect many different areas of the application. The code is isolated in base/handlers.cljs and handles setting the db to the correct search term. Now for the panel that is active I might need to also trigger some logic when the search term changes like reseting the current page to 0 and starting a search again. The panel logic is in panel1/handlers.cljs what is the best way to trigger my hander code in panel1 when the search term in the db is updated by the base/handlers.cljs.
@ckirkendall: in the handler function that updates the search term in base/handlers.cljs I would further dispatch to a function in panel1/handlers.cljs that keeps the search term in sync in the local db
That couples the base code to the panel and in this case all panels since the search scopes sub panels. That is what I am trying to avoid.
@ckirkendall: we're doing something similar, we take a couple strategies. We either dispatch to the base handler from the panel handler or pass a "callback" dispatch key to base.
(rf/dispatch [:base/search [:panel/search]])