Fork me on GitHub
#re-frame
<
2015-11-11
>
gregg00:11:27

:size did pop up into my mind but it seems I misinterpreted your question. Yes, you can do a lot with :size. If you haven't already, please read this important page: http://re-demo.s3-website-ap-southeast-2.amazonaws.com/#/layout

gregg00:11:50

especially the bottom part which talks about :size

gregg00:11:59

There's also a :size button at the bottom of our h-box demo page on the right where you can interactively play with it

gregg00:11:16

and the :size2 button as well

richiardiandrea00:11:54

yep, you know, I find myself always going to that page to remember what is the mapping between none and `"g s b" šŸ˜„

gregg00:11:15

I still find it helpful myself simple_smile

richiardiandrea00:11:32

and a question, if I have pure hmtl to display, to I have to convert it to hiccup for using it in :label for instance?

richiardiandrea00:11:17

because a div with dangerouslySetInnerHTML does not play well with flexbox (as you noted in the demo šŸ‘)

gregg00:11:57

I have not played with dangerouslySetInnerHTML myself so can't comment (where is it mentioned in the re-com demo?). I always convert any HTML to hiccup.

richiardiandrea00:11:55

ok is not dangerously... per se, but there a warning in Warning: Be All In šŸ˜„

gregg00:11:20

Ahh, ok. Then danger... might still might be possible as long as the inserted HTML has the appropriate Flexbox styling

richiardiandrea00:11:13

will try to convert because I have very strange behaviours with dang.. (I'll leave you four letters to play with šŸ˜„ šŸ˜„)

upgradingdave20:11:58

Hi all, Iā€™ve been digging into re-frame, itā€™s really nice. I have a quick question - any examples or advice for chaining ajax calls? For example, in a photo gallery app, I have a :get-user handler and a :get-photos handler. :get-photos can only happen after :get-user. My current strategy is to have logic in the :get-user handler and fire a dispatch to :get-photos only when needed; does that sound reasonable?

roberto20:11:59

itā€™s what I do.

upgradingdave20:11:59

Just curious if chaining ajax calls is a code smell? Maybe :get-photos and :get-user should be one atomic thing?

jstew20:11:44

That's reasonable. The only difficulty I've had in loading data is that I like to display a loading animation, but when all of the data is loaded asyncronously it's hard to tell when the loader should be disabled.

upgradingdave20:11:25

yeah, makes sense. I have logic in the components so that if photos arenā€™t available, then the photo reagent component, for example, displays ā€œloadingā€. So I think from that perspective it should work ok. Although, Iā€™m not a fan of the page loading bits and pieces at a time, so maybe Iā€™ll do a few dispatch-syncs to start with. Thanks for the insights

roberto21:11:14

I have a field in the app state that indicates if it is loading

jstew21:11:24

What if you have two things that are loading at the same time? One may return before the other and put the app-db in a bad state? Or do you have :users-loading and :posts-loading for instance?

roberto21:11:30

so, normally for those cases, those things are a map

roberto21:11:32

for example:

{:my-list-of-things {:loading? false :items []}
 :my-other-list-of-things {:loading? false :items []}}

roberto21:11:19

Iā€™m not an expert, btw, this is just how Iā€™ve dealt with use cases like this. Would love to know what ppl with more experience have done.

nbdam21:11:02

i just increment and decrement :loading-count... it works well enough for me..

roberto21:11:36

@nbdam what @jstew was referring too was when you want to track the loading progress of more than one item.

roberto21:11:28

for example, you might have two components, that each load their own data, and you can show some message while they are loading...

nbdam21:11:33

so was i.. or i am missing something? is count > 0 than something is loading...

roberto21:11:17

hadnā€™t thought about that

roberto21:11:44

Iā€™ll have to try that and see how it works. It sounds like a good idea.

nbdam21:11:27

how do you guys share key paths between subs and handlers?

nbdam21:11:59

if i have a nested data model and don't want to repeat the path prefix everywhere?

nbdam21:11:30

if subs where references i would share the reference.. this way it seems more complicated...

jstew21:11:45

I was thinking about trying the same thing... the increment and decrement idea.

nbdam21:11:51

@jstew just remember to clean it up in case of failure also and it should be fine for the most basic loading indicators...

mccraigmccraig22:11:49

@roberto: another way is to use alet and promesa - http://funcool.github.io/promesa/latest/#advanced-chaining - then you don't need to put anything in the db until you have everything you need. it's a bit harder to bend your brain around, but worth the effort

roberto22:11:36

yeah, I didnā€™t want to use too many 3rd party libs.

roberto22:11:22

and didnā€™t like working with promises in JS that much.

dd22:11:30

Before 0.5.0, I was able to print out console logs to the browser inside handler functions. After 0.5.0, my logs appeared to get swallowed and are not printed to the browser window. Has anyone else experience this issue? Any ideas how to get around it?

dd22:11:39

this is the log function I am using

dd22:11:45

(defn mlog
  "Logs entire vector of messages to browser console."
  [& messages]
  (.apply (.-log js/console) js/console (clj->js messages)))

roberto22:11:30

hmmm, shouldnt it be (.log js/console) ?

roberto22:11:33

that works for me

roberto22:11:04

(.log js/console (clj->js messages))

mccraigmccraig22:11:22

@roberto: using the applicative and monad abstractions and their associated alet/mlet binding syntaxes makes working with promises much more straightforward

roberto22:11:42

Iā€™ll have to see it used in a real project. The impression I get from just reading the docs is that it feels very unnatural (in clojure).

roberto22:11:48

and Iā€™m very scared of Promises in the browser. My experience when something goes wrong has not been very pleasant. The stack traces are not very helpful.

darwin22:11:58

@dd this is unrelated, but you should implement mlog as a macro, to preserve call site location in devtools console, also give this a try instead of doing clj->js: https://github.com/binaryage/cljs-devtools

roberto22:11:36

didnā€™t know about that one

dd22:11:13

@darwin - thanks Iā€™ll take a look

roberto22:11:27

how do you isolate it only for dev?

roberto22:11:38

it seems like it will leak into prod too

darwin22:11:07

cljsbuildā€™s :source-paths ?

darwin22:11:16

that is how I do it

darwin22:11:07

sample does not really have a production build (a room for improvement)

roberto22:11:09

this is what I was referring too

darwin22:11:45

I include src/dev in :source-paths of dev builds only

darwin22:11:57

production code doesnā€™t get to see those sources at all

dd22:11:25

@darwin: Thanks Iā€™ll take a look

jaen23:11:31

cljs-devtools is bee's knees

mikethompson23:11:34

There is a library for debugging macros: https://github.com/noprompt/shodan