This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-16
Channels
- # 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)
@mikethompson: how would one go about doing that?
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
Do you use debug
middleware ?
It side effects.
It writes to console
So via middleware you can capture anything.
undoable
is middleware too
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"))
(yes, I'm using secretary)
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)
It uses secretary
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?
@mikethompson: yes exactly, I started from there and edited
So I guess the issue is in the second defroute
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
what dyu mean by "multiple ratoms" @conaw ?
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.
to quote @mikethompson
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 reaction
or ratom
like things in there
correct
@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.
I am trying to avoid coupling the base code and the panel code.
@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
makes sense?
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.
I can't see an alternative honestly 😕
yeah I am struggling coming up with something clean
@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]])
There is something in the core that allows me to add-post-event-callback
It sounds like what I am looking for.