Fork me on GitHub
#re-frame
<
2016-12-02
>
andre03:12:29

@sandbags hi, where are you looking the homepage? https://github.com/flexsurfer/re-frisk here is 0.3.1 the latest version with the fixed scroll, but i would recommended using external window debugger, because more features, i want to get rid of panel, it's only need for clojure/conj 🙂

sandbags07:12:28

@andre sorry i think i must have added the dependency earlier and only used it yesterday, then thought i’d added it yesterday when i ran lein ancient

sandbags07:12:40

My brain working hard not to make it my fault 🙂

sandbags07:12:24

When you say “use external debugger” I am not sure if you mean “use something else, not re-frisk” or “use the re-frisk in its own window” option

andre07:12:55

it's because my english, sorry, i mean use the re-frisk in its own window

andre07:12:24

there are more functionality for the reframe, events , and state export

sandbags08:12:34

@andre yep.. i have used the window and it’s cool, getting the events was a nice bonus

sandbags08:12:51

@andre thank you for making re-frisk … it’s handily replaced my crappy “debug view” in the app

andre08:12:36

glad to hear , thank you, in plan i whant to add re-frame effects and subscribtions lists

sandbags08:12:47

@andre one suggestion though, if you’ve a moment, if you can replace [Object Object] (I’m going from memory here) with something shorter it would help

sandbags08:12:51

I have some cases where i have maps with a lot of keys that are Clojure records that end up being represented [Object Object] and it takes up a lot of space visually when some short-hand would be better

andre08:12:00

yes, good idea, because there can be something like generated js functions body

sandbags08:12:05

It’s a pity I can’t make those records more useful… they are basically wrappers for an id

andre08:12:18

i'll create the task for enhancement

sandbags08:12:25

as a design choice i often question their value

sandbags08:12:44

but, yes, that would be useful thank you

sandbags08:12:52

@andre i can think of one instance in which the panel approach could be very useful: if you could “focus” the panel on a specific sub-tree of db and turn it into a kind of “watch"

sandbags08:12:26

then you just have the value you are interested in, right in your visual focus where you want it

andre08:12:18

@sandbags so , there are alot of data that changing, but you want only watch some current value?

andre08:12:34

ok, understand

sandbags08:12:18

for example i track both date and a day delta. When I was testing the code that updated them together i would have loved to be able to focus on the matching part(s) of the data structure

sandbags08:12:36

sweet, thanks … i admire your discipline!

andre10:12:19

@sandbags

(re-frisk.core/add-data :mywatcher (reagent.ratom/make-reaction (fn [](:data @re-frame.db/app-db))))
you can run this in the REPL, this is workaround for “focus” the panel on a specific sub-tree

andre10:12:36

you need just specify :mywatcher keyword and :data path in the app-db

andre10:12:56

i know it's not user friendly but maybe will be helpful

sandbags13:12:09

@andre thanks, i will try that out!

borkdude13:12:31

How do I get to the updated arguments in :component-did-update?

borkdude13:12:58

For example:

(fn [foo]
  (reagent/create-class
     {:component-did-mount
      #(side-effect! foo)
      :reagent-render (fn [foo] [:div#foo])}) 

borkdude13:12:16

This doesn’t work when the foo args are updated

borkdude13:12:46

(double post from #reagent)

sandbags17:12:56

I am having a problem and I think I know why but I’m not sure what to do about it. Within my app-state I have a map one of whose values refers to a component that will represent the “main view”. Events can change the main view by updating this. What I used to do was use a keyword and I had a case statement like (let [view (…)] (case view :foo [foo/foo-view] :bar [bar/bar-view])) and so on (in reality a little more complex but that was the essence of it). I didn’t like that so I decided what if I just stuff the symbol for the component into the db, now I can just do (let [view (…)] [view]) which works except that when I update the view code the view is reloaded but I am still looking at the old component output. I now think it may be related to how code re-loading works and having the symbol in a data-structure I am some-how hanging on to the ‘old' component function whereas referring to the symbol directly yields the output of the updated component function. Maybe... Anyone know for sure what is going on here? And can anyone suggest how I can dynamically switch views from the database without hard coding a lot of symbol lookup? Was thinking maybe of using :foo/foo-view and trying to turn that into a symbol at run-time. Would love to hear, how are other people solving this problem?

sandbags17:12:46

I’m wondering if the “resolve by name” approach is feasible in ClojureScript since it doesn’t have ns-resolve and I see suggestions the Closure compilers optimisations make it unworkable.

akiroz17:12:59

@sandbags I think what you want is store the symbol in the app-db like 'foo/fooview (note the quote) and when you take it out, resolve that symbol to the actual view

sandbags17:12:23

ah, of course… i am probably storing the actual JS function

akiroz17:12:22

wait... does cljs have resolve ?

sandbags17:12:44

I don’t think so as resolve is a short-hand for (ns-resolve *ns* …)

akiroz17:12:11

I found cljs.analyzer.api/resolve but the doc is 404...

sandbags17:12:47

hrmmm if i can’t use resolve i can’t use the symbol unless I am missing something obvious

sandbags17:12:32

i’m having a brain fade moment… how do I turn ‘foo/foo-view into foo/foo-view … it’s via ns-resolve right?

akiroz17:12:15

I believe so

sandbags17:12:09

sadly it looks like i might be back to my ugly case statements

sandbags17:12:13

that’s rather disappointing

sandbags17:12:26

but i am struggling to believe there is no more elegant solution to this…

mccraigmccraig17:12:18

@sandbags you can use a multimethod instead of case ... lets you declare the multimethod near where it is used, and define the render implementations wherever they belong

sandbags17:12:30

Ah so you mean I define a multi like main-view and a set of methods for each component view and use the keyword to switch on method

sandbags17:12:39

that’s nice!

sandbags17:12:10

thank you, elegance achieved 🙂

sandbags17:12:37

awesome thanks for that

mccraigmccraig17:12:21

i would only use form-1 components with a multi-method though - i think you might find weirdness with form-2 or form-3 components

sandbags17:12:48

ah, that could be an issue

sandbags17:12:06

most of my views are form-(n>1)

sandbags17:12:14

and depend on subscriptions

mccraigmccraig17:12:28

remember that in re-frame 0.8 and above you can use subs efficiently in form-1 components... i think form-2 components are kinda obsolete now

sandbags17:12:58

oh i do remember seeing some discussion of this

sandbags17:12:19

right, i guess i have some work to do

mccraigmccraig17:12:00

@sandbags have a look down the bottom of https://github.com/Day8/re-frame/issues/218 "It is now officially guaranteed that you can use subscribe in a Form-1 Reagent view function. This guarantee will officially be a part of the 0.9.0 release, but it already works in v0.8.0."

sandbags17:12:01

was the solution to using subs in form-1 simply to move them into the component function? Or was there other work you needed to do? (Essentially I am asking if I need to go look up where this was described or if the easy path is the right one)

sandbags17:12:06

ah, thank you 🙂

akiroz17:12:21

Oh cool, I love this multimethod solution~ 🙂 might refactor my code base...

sandbags17:12:28

yes i remember this issue now

sandbags17:12:02

@mccraigmccraig many thanks, again !

sandbags17:12:55

(not that i doubted you… but i doubted me!)

sandbags17:12:17

excellent, this is a really nice solution … i knew Clojure wouldn’t let me down 🙂

si1418:12:33

how would you choose between "passing down" data obtained from a subscription to a component and subscribing to the data in an underlying component directly? are there any non-obvious considerations?

akiroz18:12:27

I usually have the components subscribe directly because it could re-render seperately, if you pass data down, the whole thing would always re-render

akiroz18:12:14

on the other hand, this makes your components harder to decouple from your app, you'll need to write a stub for the subscribe/`dispatch` functions to test your component seperately.

shaun-mahood21:12:57

Man, whoever gets these online is fast! Here's my talk from the Conj, only 2 hours from completion to youtube https://youtu.be/cDzjlx6otCU

si1422:12:30

@akiroz thanks a lot!