Fork me on GitHub
#re-frame
<
2016-12-17
>
cmal03:12:23

Hi! If I use path interceptor, then in this event handler, I can not refer to keys other than the one specified by path, right? If this is not right, how should I use (path :key-a) and at the same time refer to (:key-b db)?

andre08:12:50

i think the idea of path is to change value in path 🙂

cmal08:12:30

When we change the value of (:key-a db), can we use the value of (:key-b db), if we use (path :key-a) interceptor?

andre08:12:21

you don't have db in the handler, only value of (:key-a db)

cmal09:12:28

ok, Thanks!

andre09:12:02

@cmal so, if you want to change only value of (:path1 (:path2 :db)) , and you don't need any other values from :db you are using path, for example you want to set visible to true (:visible (:window :db)) , and you dispatch [:visible true] , if you want something more from :db you are not using path 🙂

cmal10:12:17

@andre Thanks. So I think the path interceptor is useful only if data in the path depends on nothing else in db.

cmal11:12:14

Solved! I've moved the mount-root window-width, and on-window-resize to views.cljs and it works. --- original question --- Hi! I am adding an on-window-resize event handler to my re-frame project. I looked to reagent's doc and found this: https://github.com/reagent-project/reagent-cookbook/blob/master/recipes/canvas-fills-div/README.md#step-3-add-an-atom-and-event-handler-for-tracking-the-size-of-the-window , which shows adding window-width, on-window-resize and (.addEventListener js/window "resize" on-window-resize) to main function. I've added them to the mount-root function of re-frame-template, then I want to refer to window-width and on-window-resize in views.cljs. If I use [my-project.core] or something similar in views.cljs, it will show circular dependency detected. What is the right way to do this? Thanks!

upgradingdave16:12:37

Had a lot of fun writing this widget over past few evenings. I learned a ton; cofx, :dispatch-later, undo (incredibly easy to integrate btw!), and how to use third party react components (take a look at flip-move in case you need to animate lists). Thanks for the support and great documentation!

upgradingdave16:12:04

(scroll down to the bottom of the post to see the demo)

mikethompson22:12:50

@upgradingdave Oh, I love that, thanks. We will be having a close look at how you pulled this off, first thing Monday.