Fork me on GitHub
#re-frame
<
2017-11-20
>
scknkkrer01:11:19

Does anyone have using Fetch API with re-frame ?

scknkkrer02:11:43

Actually, I am writing a library. A wrapper for Fetch API. But I don’t know will you guys use it or won’t. @mikethompson

mikethompson02:11:43

We currently use re-frame-http-fx, and unlikely to move in a hurry. But if you want to wrap fetch then re-frame-http-fx might act as a good tutorial/template.

scknkkrer02:11:33

Yeah. I am so newbie. But this is a good step for me. It’s proud to make something for my comunity. @mikethompson 😇

cjsauer03:11:10

Quick question: when I create a component in this way (from the readme):

(defn clock
  []
  [:div.example-clock
   {:style {:color @(rf/subscribe [:time-color])}}
   (-> @(rf/subscribe [:time])
       .toTimeString
       (clojure.string/split " ")
       first)])
Will this re-create the subscription on each rendering of the component? I imagine subscriptions use some kind of listener mechanism, and I don't want to be taxing the GC too much unnecessarily.

cjsauer03:11:20

How does the above differ from creating the subscription in a top-level let block, and then returning a higher-order function?

lovuikeng04:11:15

use let if data initialization is needed

mikethompson06:11:05

@cjsauer subscriptions are cached and de-duplicated. So, yes, the subscription is recreated each time the component rerenders, except, no, it isn't actually recreated because it is found in the cache and simply reused.

cjsauer15:11:04

Awesome, thanks for the help

cmal07:11:51

Hi, I found the keys used in reg-event-db and reg-sub and so on becomes strings after google compiler's advanced-mode so the events takes so much space in the compiled javascript files. Is it possible to make the keys used in reg-event-db and reg-sub be replaced by google compiler?

cmal07:11:20

like this: var Jj=new M(null,"annc-toggle-display-type","annc-toggle-display-type",-302319952)

cmal07:11:00

:annc-toggle-display-type is one of the keys I used in re-frame's handlers or subscribers.

mikethompson09:11:06

@cmal you are using keyword ids, right (when using reg-event-db, etc)?

mikethompson09:11:29

If so, keywords take up next to no space.

sb13:11:56

Hi, what is the best bootstrap + re-frame solution like re-com, just responsible? Maybe somebody saw a good solution

mikerod14:11:17

Have you tried just using the cljsjs/react-bootstrap ? For the most part I’ve had no problems using that

mikerod14:11:52

Just have to do reagent.core/adapt-react-class on the things you want to use to use them as any other Reagent-style component

sb15:11:25

Ok, thanks! I check it!👍

sb13:11:38

or integrate elements like at hiccup?

achikin14:11:06

Hi! How do I get response headers in :http-xhrio success handler?

deg14:11:33

@mikethompson - I just looked at the compilation results of one of my projects and I see what @cmal means. A keywords that is used only as an event or sub name results in the string of its name being retained in the optimized output. (Unlike, e.g., functions that get obfuscated down to nearly nothing). In a re-frame app with many subs and events, these strings might add up to some substantial amount of space.

oliy14:11:17

Hi, if anyone uses Emacs and would like to be able to jump to the definition of a re-frame registration from its use, I wrote a little elisp to help. Feedback welcome, I wrote it today but it's been working wonderfully for me so far! https://github.com/oliyh/re-jump.el

achikin15:11:42

Great, thank you!

gadfly36115:11:11

Try baking-soda .. it is like soda-ash but for bootstrap

sb15:11:48

thanks! I check it!

gadfly36115:11:36

@oliy excited for this!

cmal17:11:29

Hi, @mikethompson. Thank you for your response. I does not quite catch you. Are you asking how I define a event handler? I write codes like this:

(reg-event-fx
 :annc-toggle-display-type
 (fn [{:keys [db]} [_ t]]
   {:db       (let [t (if (= :stock (get-in db [:annc :display-type]))
                        :date
                        :stock)]
                (-> db
                    (assoc-in [:annc :display-type] t)))
    :dispatch [:loader-set-show false]}))

cmal17:11:23

And I found something like var Jj=new M(null,"annc-toggle-display-type","annc-toggle-display-type",-302319952) in the advanced compiled code.

cmal17:11:58

I am not sure how the compiler will deal with these keywords, but I thought those keyword could be replaced by shorter ones to save space. But they are not.

danielcompton20:11:19

@cmal when you say it takes up a lot of space, what kind of numbers are we talking about?