Fork me on GitHub
#reagent
<
2017-05-26
>
spinningarrow13:05:16

I've made a little app with reagent and I've been running it in dev with figwheel. How do I create a deployable production build with all the js minified, concatenated, etc?

pesterhazy13:05:16

if you've used the figwheel template (`lein new figwheel`), you can use lein cljsbuild once min

spinningarrow13:05:57

I used the reagent-frontend template; is that similar?

spinningarrow14:05:59

Hmm I get java.lang.Exception: Unknown build identifier: min

pesterhazy14:05:16

looks like there's a "release" profile, so try lein cljsbuild once release

jtth14:05:36

If I’m not using re-frame, where do I put the calls to a backend API to set up my initial app state on page load?

souenzzo14:05:44

@jtth There is a :init-db event. This evento should be -fx, and return something like {:db {,,sutfff,,,} :dispatch [[:fetch-api :param :other] [:fetch-other-api :param :other-2]] }

souenzzo14:05:22

(each event should do a single fetch)

jtth14:05:45

ah! I’ve just been shoving stuff into the global state with session/put! like an animal. no wonder on initial page load it doesn’t work.

jtth15:05:02

not using re-frame at all

jtth15:05:03

just reagent

souenzzo15:05:35

Oh, So my answer is wrong.

jtth15:05:55

basically i have two api calls, one dependent on information loaded into the app state by the other, and the second one seems to fire before the first one loads into the app state

souenzzo15:05:11

On reagent, there no standard way to manage the state of aplication. You can, for example, declare a initial state (defonce state (r/atom {})) Then, on main, before render, "dispatch" your fetchs (for [i stuff] (doto fetch (js/fetch "") (.then (fn [response] (swap! state :respose-1 response)))))

jtth15:05:54

ah, okay. thanks!

souenzzo15:05:32

On async/browser/reagent isn't good think in tems of "after/before". Reagent render your state. Async requests update your state. You can make on your render (if my-state not contains all stuff then render "loading")

jtth15:05:41

i should probably jsut learn re-frame eventually

jtth15:05:58

that’s agood point, thanks

dimovich19:05:09

@jtth I used plain ajax calls

dimovich19:05:20

How do I get to change the size of a child component on parent resize?

dimovich19:05:30

what's the best way to do it?