Fork me on GitHub
#re-frame
<
2019-08-27
>
scknkkrer11:08:33

Guys, I want to keep my User Configurations up-to-date with Local Storage.

(def set-user-interceptor [(path [:user :internal])
                           (after (partial set-item-ls conduit-user-key))  ;; write user to localstore (after)
                           trim-v])

scknkkrer11:08:16

path call was like (path :user). But, I wanted to change it another structure.

scknkkrer11:08:30

It still cache the :user.

scknkkrer11:08:38

How can I deal with it ?

scknkkrer11:08:54

I couldn’t find any documentation or blog-post ?

jahson11:08:15

Which documenation are you searching for?

mkvlr11:08:56

does anybody here use re-frame without subscriptions? Wondering how significant the performance penalty is. As I understand it components don't rerender when their input subscriptions don't change.

scknkkrer13:08:17

Have you guys ever tried this ? https://github.com/Day8/re-frame-10x My configuration is valid but, it insistently spits repeated file to Google Closure dependencies.

:dev-front {:source-paths ["src_front" "src_front_profile/desktopnew_front/dev"]
                                   :incremental true
                                   :jar true
                                   :assert true
                                   :compiler {:output-to "app/dev/js/front.js"
                                              :externs ["app/dev/js/externs_front.js"]
                                              :warnings true
                                              :elide-asserts true
                                              :npm-deps false
                                              ;; :target :nodejs
                                              :closure-defines      {"re_frame.trace.trace_enabled_QMARK_" true}
                                              :preloads             [day8.re-frame-10x.preload]
                                              :main                 "desktopnew-front.core"
                                              ;; no optimize compile (dev)
                                              :optimizations :none
                                              :output-dir "app/dev/js/out_front"

                                              ;; simple compile (dev)
                                              ;;:optimizations :simple

                                              ;; advanced compile (prod)
                                              ;;:optimizations :advanced

                                              ;; :source-map "app/dev/js/test.js.map"
                                              :pretty-print true
                                              :output-wrapper true}}

scknkkrer13:08:14

It spits:

document.write('<script src="app/dev/js/out_front/goog/deps.js"></script>');
document.write('<script src="app/dev/js/out_front/cljs_deps.js"></script>');
But the valid path is /js/out_front/goog/…. It adds the repeated app/dev/ part to it.

scknkkrer13:08:40

If I manually remove the repeated part. My project works!

dpsutton15:08:19

I'm handling a ::form-submitted reg-event-fx. I need the current user. Right now it has (let [user @(rf/subscribe [:state/user]) Is this fine? Should I make an interceptor or coeffect that provides the user? Or is there some other strategy that I should be using?

jahson15:08:39

@dpsutton So, you're using subscription in an event handler?

dpsutton15:08:05

not sure if this is a code smell or intended behavior

dpsutton15:08:26

i suppose i could have the event trigger pass it in but just seeing if there's another way

dpsutton15:08:56

also this is probably a bit pervasive so want to know if this is a spend a friday and fix it totally, clean up as you go boyscout style, or totally fine

jahson16:08:12

It's not an intended behavior, I couldn't remember the place where a situation like this is described. I think the best way is to add a coeffect.

dpsutton16:08:00

is there a prebuilt coeffect for a subscription? or will the coeffect be (assoc cofx :user @(rf/subscribe [:state/user])) essentially?

dpsutton16:08:53

oh thank you so much

dpsutton16:08:19

ah, its the dispose-maybe that's important

lepistane17:08:56

How do you guys deal with re-frame apps that need to have bookmarks? I mean i want to have list of items and when i click on item - url changes so i can send ulr to a friend and he will see the same i am considering of using kee-frame but i imagine there has to be a way to do this with re-frame do you have any examples?

deadghost18:08:36

is there a maintained re-frame cookie fx thing?

deadghost18:08:09

https://github.com/SMX-LTD/re-frame-cookie-fx the 2017 last commit doesn't bring confidence

Lu18:08:35

I’m using this lib and it works fine

Lu18:08:21

The core is 160 lines of code .. it’s not that it is supposed to do much 😂

deadghost18:08:17

yeah but anything js has a short shelf life

deadghost18:08:42

2 years is plenty of time for things to just stop working

Lu18:08:58

True :)

deadghost18:08:52

not to mention the 0.0.2 versioning

jahson18:08:18

@lepistane You'll probaly need a backend, which have an API that allows to save and retrieve data, and some kind of persistent storage, where the data is stored. Then you'll need a frontend router which will have routes for a list of items and for an item. And of course you'll need some kind of app that will handle loading and saving the data. These days it's often a SPA with some API backend, in the past it was often just a server-side app that served the HTML. Basically, an app like this don't have a requirement for a complex frontend part at all. So, any example with some kind of backend with persistent storage, and afrontend router will match if you want SPA.

jahson18:08:46

@deadghost It's ok for clojure libs though. And fx for cookies is pretty simple I guess.

lepistane20:08:19

@jahson backend is fine i was interested in re-frame way of doing things in router i'd want url/page/abc and on load of that page to dispatch request to backend for page with id=abc i guess the example would be this https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/core.cljs#L34

jahson21:08:15

Yeah, you might go this way. Or you could use any other router. On route match you'll dispatch an event and in event handler you'll fire the request to load the data.

jahson21:08:53

It uses the :http-xhrio effect to load the data from the backend.

jahson21:08:33

(btw there's https://github.com/Day8/re-frame-http-fx-2, but the readme warns that it's not ready)

jahson21:08:31

After the data is loaded successfully, the :get-articles-success is dispatched https://github.com/jacekschae/conduit/blob/master/src/conduit/events.cljs#L146-L152

jahson21:08:00

And the db is updated with articles, the subscriptions are updated (all of the Layer 2 and some of the Layer 3), the UI is rerendered where the changed subscriptions were used.