Fork me on GitHub
#cljsrn
<
2016-06-17
>
savelichalex06:06:37

Guys, does anyone use environment variables with RN? Smth for dev and prod mode in code?

savelichalex06:06:15

And another question, is it possible to use plists for configs?

vikeri06:06:06

@savelichalex: Yes, I use Google Closure variables as per: https://github.com/drapanjanas/re-natal/issues/46#issuecomment-219284294 No idea about plists. Was looking into it a while back but never decided on anything.

vikeri07:06:19

@savelichalex: :thumbsup: It is not ideal however, I have a script that overwrites the figwheel-bridge.js

savelichalex07:06:04

@vikeri: Can you show it?

savelichalex07:06:36

@vikeri: I’m just thinking how use it with bash variables)

vikeri07:06:43

@savelichalex: Alright, in project.clj I think you can use (System/getenv ”BASH_VAR”)

savelichalex07:06:03

@vikeri: Do you mean that do it in project.clj instead of overwrite figwheel-bridge.js?

vikeri07:06:30

@savelichalex: I don’t know where you are using what, if you want to use bash variables as a closure define you could just replace true in the script above with $VAR?

vikeri07:06:23

But that script is just intended to run after a re-natal use-figwheel

savelichalex07:06:32

@vikeri: hm, nice decision with $VAR, I like it:smile: thanks again)

vikeri07:06:24

:thumbsup:

savelichalex07:06:26

Can we use this variables with macros?

vikeri07:06:30

I think so, but then you would use (System/getenv "BASH_VAR”) I’m not sure that is the indended use of macros though 😛

savelichalex07:06:20

It is only idea so far:smile:

pesterhazy08:06:46

@savelichalex: what I do is: 1. build step that adds a json file to the ios app bundle 2. read the json file in objectivec code 3. pass that as initial props to the cljs code

pesterhazy08:06:38

that allows me to specify settings by environment (the build script injects a different json file depending on the env)

savelichalex08:06:35

@pesterhazy: Do you have an example?

pesterhazy08:06:55

@savelichalex: it's a bit hard to extract from our code right now

pesterhazy08:06:03

not very elegant either

pesterhazy08:06:22

my point is mostly that env variables are not the best solution

savelichalex08:06:48

@pesterhazy: I’m just want to know more specific technical details on each step. I’m really don’t want to invent it by myself because i’m not an expert:slightly_smiling_face:

savelichalex08:06:44

@pesterhazy: what do you mean by «ios app bundle»? this is js file?

pesterhazy09:06:00

that's basically the directory that holds all your app files (binary, images, offline js in production mode)

savelichalex09:06:21

@pesterhazy: It seems that I have to deal with this) another noob question, how you pass that as props to cljs code?

pesterhazy09:06:37

@savelichalex: in AppDelegate.m:

self->rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"Fy"
                                                  initialProperties:@{@"foo": foo,
                                                                      @"deviceName": [[UIDevice currentDevice] name]
                                                                      }
                                                   launchOptions:launchOptions];

pesterhazy09:06:34

that's just an example; if you read a json file in objc, it'll give you a dictionary

pesterhazy09:06:43

you could pass that to the rootview

savelichalex09:06:25

and this is app-root component?

savelichalex09:06:44

got it) thanks!

savelichalex09:06:17

It’s time to create blog with all this notes about RN:smile:

pesterhazy10:06:23

oh yeah, agree

vikeri12:06:23

Jesus, really frustrating that there is not a single reference to my actual cljs-code in the error messages… @pesterhazy: are the error messages better in boot-react-native?

vikeri12:06:00

(For runtime errors)

pesterhazy12:06:04

depends on the kinds of error messages

vikeri12:06:10

Runtime errors?

pesterhazy12:06:20

javascript stacktraces?

pesterhazy12:06:54

you can have the stacktrace printed out to the console so it does give you context

pesterhazy12:06:19

but sourcemaps don't work reliably with b-r-n yet afaik

vikeri12:06:25

Yes, but the only reference to cljs is to figwheel-bridge no cljs files are referenced.

savelichalex12:06:04

I’m use console.log based error detection:smile:

pesterhazy12:06:41

yes, in bad cases console.log is needed

vikeri12:06:07

To manually step through the program until the glitch is found?

savelichalex12:06:50

This is depend how you write program. With figwheel you always see result and then if error happened then just put log in last changes

savelichalex12:06:25

one day I wrote a lot of code before run and debug was painful)

vikeri12:06:08

Yes, I was working with forming data structures so I didn’t look in the app at all.

vikeri12:06:45

But just to clarify, runtime errors are not traceable to a cljs ns in boot-react-native either?

savelichalex12:06:20

@vikeri: maybe repl help you with data structures? 😉

pesterhazy12:06:38

as I said, you get a normal stacktrace, which of course includes the namespaces

vikeri12:06:44

@savelichalex: Yes that is what I’ve been doing. But then copying the functions into the ns creates trouble. @pesterhazy: Ok then that is a very compelling argument to switch to boot-react-native…

pesterhazy12:06:32

be careful with current boot-react-native native though

pesterhazy12:06:43

it's broken for me

vikeri12:06:07

Yeah, I’ll probably wait until you guys sort it out for 0.27 before I switch 😉

anatoly14:06:28

Hey guys, I am using cljs-ajax to do ajax calls from react-native (On Android). Everything but the GET calls are working perfectly – but calling GET does not do any network operations (checked with wireshark) and calls the error handler with the following parameters: {:status 0 :status-text "Request failed" :failure :failed} Minimal example:

;; This does not work
     (ajax/GET ""
               {:params  {:foo :bar}
                :error-handler #(js/alert %)})
;; This works perfectly
     (ajax/PUT ""
               {:params  {:foo :bar}
                :error-handler #(js/alert %)})
Do you have any hints why this happens and how to fix it?

jurgen_photek18:06:17

@anatoly: I recall I had the same issue. looked back to find details... not got much. I know it was android-only problem and i switched to using js/fetch which worked fine

anatoly18:06:02

@jurgen_photek: Thank you – I will try it out.