Fork me on GitHub
#re-frame
<
2018-05-08
>
Hukka07:05:18

@danielcompton It's a bit surprising that 10x needs .5, when in the project.clj it declares a dependency on .3 only

Hukka08:05:10

Updating to .5 fixes the app-db visibility

danielcompton09:05:06

Thanks, I've updated the dependencies for re-frame

danielcompton09:05:52

Because it's a provided dependency it doesn't affect which version your app gets, but I can see how it would be confusing

borkdude10:05:26

hah, funny. I had a “maximum call stack exceeded” in the console. turns out I made a recursive subscription by accident 😉

timo10:05:53

it works in firefox though

mikethompson10:05:06

@timok You mean "the green bit" is entirely unresponsive to mouse clicks intended to "open up" the tree?

mikethompson11:05:21

Including the triangles further "into" the data structure?

mikethompson11:05:35

Some mixup between reagent/React/re-frame/re-frame-10x versions ?

timo11:05:16

that might be the case...I had problems with deps and hardcoded the react-version

timo11:05:26

[org.clojure/clojure "1.9.0"]
                 [org.clojure/clojurescript "1.10.238"]
                 [cljsjs/react-dom "16.3.0-1"]
                 [cljsjs/react-dom-server "16.3.0-1"]
                 [cljsjs/create-react-class "15.6.2-0"]
                 [reagent "0.8.0"]
                 [reagent-utils "0.3.1"]
                 [re-frame "0.10.5"]
...
                 [day8.re-frame/re-frame-10x "0.3.3"]

timo11:05:53

Thanks a lot...will try that! aw_yeah

mikethompson11:05:07

Also, should [cljsjs/create-react-class "15.6.2-0"] be for 16

timo11:05:37

@mikethompson what do you mean? should I take it out? because there is no major version 16 available from cljsjs

mikethompson11:05:07

I think that mixing React15 and Rect16 will cause problems.

timo11:05:19

alright, thanks

timo11:05:43

maybe it is better to stick with react version 15?

timo11:05:54

mmh...reagent 0.8 pulls in these deps...I think I copied it from there and hardcoded it... so it's a mix there

Bravi11:05:01

I have users list in my re-frame db. whenever I load users-list page, I have (re-frame/dispatch [:events/fetch-users] event firing. And in there I have something like (when (not (empty? users))).... Every time a user navigates to this page, fetch-users is being fired, but there’s almost a second where the old data shows up, because users list is not empty after the first fetch. So I have two options as I can see - either reset the users list within fetch-users event, or to add component-will-unmount lifecycle to this component. I really don’t like using lifecycles that much in reagent / re-frame. So I was wondering how do other handle such situations? do you use lifecycle events in these situations?

juhoteperi11:05:44

create-react-class "15.6.2-0" works for React 16

Bravi11:05:27

but then I would be firing two events right?

Bravi11:05:51

one to reset the state of users and the other to re-fetch

Bravi11:05:09

is that better over having just 1 event?

timo11:05:42

I am not a specialist here but I think you can use a lot of events performance-wise

timo11:05:52

so there shouldn't be a problem

Bravi11:05:10

cool, thank you 🙂

troglotit11:05:18

@bravilogy you could dispatch :reset from inside of :fetch-users - if it makes sense that “Everytime when I fetch users, sure I want to reset what was before”

👍 4
timo12:05:21

@mikethompson 0.3.3-react16 unfortunately didn't do the trick

timo12:05:33

do you have any other idea?

juhoteperi12:05:25

Oh the problem was about re-frame-10x "data tree" not working, the triangles not opening maps etc?

juhoteperi12:05:27

Works for me now (Reagent 0.8, 0.3.3-react16) but I'm quite sure it didn't work few days ago

timo12:05:54

@juhoteperi exactly. maybe I should hit my monitor a few times... or restart... maybe tomorrow it works. 👍

timo12:05:32

lein ancient also tells me a few updates are pending...maybe this does the trick

timo12:05:36

@nenadalm thanks! I did lein clean already but will try --user-data-dir next

juhoteperi12:05:55

Chrome was running very slow (like it froze for 10 secs after Figwheel reload) for me few days ago so I reset Chrome profile and that seems to have made it faster parrot

juhoteperi12:05:12

(--user-data-dir can be used to set different profile, without resetting the default profile)

timo12:05:27

reset did it! I can open the app-db with the triangles again! upside_down_parrot

mattly13:05:30

what’s the right way to setup a subscription where I have dependently-derived data in the inputs?

mattly13:05:32

for example,

mattly13:05:30

(let [a (subscribe [:input-one]) b (subscribe [:input-two @a])] ...)

mattly13:05:21

maybe I’ll just give that a shot

mattly14:05:30

my example wasn’t very good, it’s still early here 😄 I know about this feature. What i need is more the intersection of derived state

mattly14:05:58

and it’s part-in-parcel due to my data structure being in a sort of graph structure

troglotit13:05:52

Am I right to assume that in interceptors when I modify :db in coeffects while event-handler does not use :db coeffect - it means that interceptor do nothing?

mikethompson13:05:48

@timok when you say reset did it do you mean a lein clean ?

mikethompson13:05:59

Something else?

mikethompson13:05:13

No, wait. I see now. Resetting the Chrome profile.

👍 4
mattly14:05:44

ok so to re-frame my problem (see what I did there?): I have data in a graph-like shape where any given node has both dependencies and derived data whose output is sometimes a function of those dependencies

mattly14:05:03

for example, {:a {:val 1} :b {:val 2} :c {:inputs [:a :b] :xform +} :d {:inputs [:c] :xform * :args [2]}}

mattly14:05:49

and I’d like to be able to do (subscribe [:value-for :d]) and have it pull in the values for the input nodes as needed

mattly14:05:55

if you think about this like I’m building a spreadsheet you’re not far off

mattly14:05:46

part of the problem is that for my specific problem, the derived state can be expensive to compute,

mattly14:05:03

and it’s entirely infeasible to capture that alongside the node in the app db

mattly14:05:41

I’m thinking now I might need a recursive subscription

Bravi15:05:00

is there such thing as a default header in re-frame’s http-fx? I’d like to add an auth token to every single http call and was wondering if this can be set once and not to repeat it over and over again

defa07:05:46

Since http-fx is based on cljs-ajax you might try to go with interceptors: https://github.com/JulianBirch/cljs-ajax/blob/master/docs/interceptors.md

sveri14:05:59

@bravilogy this is what I use:

(def jwt-interceptor
  (ai/to-interceptor {:name    "JWT Token Interceptor"
                      :request #(-> %
                                    (assoc-in [:headers "Authorization"] (str "Token " (uh/get-jwt-token-from-localstorage)))
                                    (assoc :format (ajax/transit-request-format)))}))

mikethompson21:05:53

@mattly if I understand you, the structure of your signal graph is described in data held in app-db. reg-sub is good for capturing a static structure. So, perhaps use reg-sub-raw instead?

mikethompson21:05:05

It is more flexible but less convenient

mattly21:05:25

thanks, will take a look

mattly21:05:41

and yes, you understand correctly

mattly12:05:18

thanks, this works beautifully. I was even able to leverage my existing subscriptions and not have to deref the appdb

hoopes23:05:33

Has anyone used re-frisk with re-natal? i'm following the instructions here https://github.com/flexsurfer/re-frisk/wiki/Using-re-frisk-with-re-natal and the server starts, but the contents of the 3 panels are just a green "not connected" - is there a step missing, or is there some other action i need to take to get it all linked up? (I know there appears to be 10x support in there as well, but I’ll get to that after getting re-frisk at least connected)