Fork me on GitHub
#cljsrn
<
2016-02-09
>
wei01:02:00

how would I translate this to cljs: import codePush from "react-native-code-push”;

wei01:02:27

I’m trying something like this but I don’t think it’s equivalent: (def codepush (.-CodePush (js/require "react-native-code-push")))

wei03:02:53

nevermind, fixed my issue. if anyone’s using re-natal and wants to require js libs, run re-natal use-component <name>

pesterhazy08:02:24

@wei, your line is equivalent to codePush = require("react-native-code-push") .codePush;

pesterhazy08:02:07

in cljs that would be (def code-push (.-codePush (js/require "react-native-code-push"))), I think

dvcrn10:02:06

@pesterhazy: not quite. import codePush from "react-native-code-push" would be codePush = require("react-native-code-push"). What you mean is import { codePush } from "react-native-code-push". That expands to codePush = require("react-native-code-push").codePush

pesterhazy10:02:48

can't say I care much for es2015 syntax

dvcrn10:02:32

I wish I could use clojurescript but right now I'm deep inside a js project 😕 At least es2015 is better than what we had before

hugod14:02:31

I'm updating a natal based om.next project to use RN 0.19, and I’m getting linker errors for Ambly classes. It looks like the lib files for the pods haven’t been built. How can I force the pods to be built?

hugod14:02:01

@mfikes: the errors are about undefined symbols, e.g. _OBJC_CLASS_$_ABYContextManager

hugod14:02:46

I also updated Ambly to 0.7.0

mfikes14:02:38

@hugod: Interesting. The first thing I’d try is opening the project in Xcode and doing a clean

mfikes14:02:53

(I don’t think I’ve ever seen that one before.)

hugod14:02:05

@mfikes: I’ve tried that already simple_smile

mfikes14:02:19

Let me see if I can repro it real quick...

hugod14:02:08

I suspect I have messed something up in the project - I’ll try creating a new project and comparing the settings. My experience with xcode is pretty minimal, so that is probably not helping.

mfikes14:02:42

@hugod: I first successfully upgraded Ambly (changed the native/ios/Podfile and did a pod update), but and then tried upgrading to RN 0.19 (changed native/package.json and did an npm update), but then encountered the fact that RCTContextExecutor.h has evidently been removed.

hugod15:02:43

@mfikes - isn’t that a change that Ambly 0.7.0 takes care of?

mfikes15:02:05

@hugod: No. Ambly is completely independent of React Native

mfikes15:02:41

That header file is referenced in the AppDelegate.m file that Natal generates.

hugod15:02:16

I replaced the AppDelegate.m with the example one from Ambly 0.7.0

mfikes15:02:23

You can see that the React Native team shifted around the way JavaScript contexts are handled.

mfikes15:02:58

Oh…, the one in the Ambly Demo project? That AppDelegate just sets up a skeletal iOS app that can run the embedded JavaScriptCore instance, etc., but it is not doing anything related to (or in support of) React Native.

hugod15:02:20

Yes, the one in the demo project. It looks like I should manually update the old AppDelegate.m file for RN 0.19 then, iiuc.

mfikes15:02:28

Yes… I think we need to figure out how to essentially replace the use of RCTContextExecutor with whatever is appropriate for the newest React Native (crossing my fingers that we actually can), and submit a patch to Dan to incorporate into Natal if it is sorted out.

mfikes15:02:51

@hugod: On the surface, that looks easy to do. I’m going to give it a shot now. It looks like they simply moved from the C API to the Obj-C API (the opposite of what I did here http://blog.fikesfarm.com/posts/2015-05-23-ambly-using-javascriptcore-c-api.html)

hugod15:02:16

@mfikes: I’m glad it looks simple to you simple_smile

mfikes15:02:51

@hugod: (It is not all that simple actually, just fortunately a path I’ve been down.)

mfikes15:02:06

@hugod: It turned out to be trivial: Replace the few references to RCTContextExecutor to RCTJSCExecutor and it cleanly compiles and works.

mfikes15:02:40

I’ll submit a PR to Dan so that it gets in the queue

hugod15:02:06

@mfikes: Thanks for the quick help!

mfikes15:02:31

@hugod: No problem Hugo. I’m in debt to you anyway for Criterium simple_smile Maybe paying off a little. simple_smile

hugod15:02:13

@mfikes: Thanks. I’m glad you find Criterium useful. It still seems I have some problem in my project though, as I’m still getting the linker errors. I’ll keep comparing with a newly generated project, or just copy my source files into a new project.

mfikes15:02:06

@hugod: Cool. Yeah, after making those two upgrades (Ambly and RN), things actually work for me. So that’s at least a sample of a working project 😕

mj_langford16:02:27

Can we currently add assets such as images directly via folder structure or do we need to do that via Xcode currently?

mj_langford16:02:56

I’m using natal, cannot find doc or by trial/error where to put images for them to be found and loaded into the bundle without using Xcode’s mechanism

pesterhazy16:02:59

with boot-react-native and a recent version of react-native, like 0.19, you can just use the packager for that

pesterhazy16:02:16

not sure how that translates to natal

hugod19:02:31

After adding a react native component (using npm), how do you access it in cljs?

pesterhazy19:02:16

@hugod, (def code-push (.-codePush (js/require "react-native-code-push")))

pesterhazy19:02:22

something like that

hugod19:02:33

Thanks, @pesterhazy, I’ve been trying something like that, but haven’t been able to get it to find anything that I js/require.

pesterhazy19:02:54

what does the packager say?

pesterhazy19:02:18

also, are you using advanced compilation?

hugod19:02:35

I’m using :optimizations :none. I don’t see the component name (react-native-camera) in the packager output. Should I?

drapanjanas19:02:55

The problem is most probably because natal (same as re-natal) loads code bypassing the packager. Packager scans for all require(..) statements and then knows what modules have to be bundled. So when code is not scanned the module you require is not available.

drapanjanas19:02:36

I guess :optimizations :simple would solve it, but then hot reloading will not work

pesterhazy19:02:28

it works with boot-react-native, because it fully embraces the packager

hugod19:02:23

@pesterhazy: Does boot-react-native work with ios?

drapanjanas19:02:57

@pesterhazy: exactly, in re-natal there is a working solution command re-natal use-component does the trick, but I do not know to implement that in natal.

pesterhazy19:02:31

I added a few changes lately to make it work pretty nicely with iOS (automatically start simulator and tail logs)

pesterhazy19:02:10

@drapanjanas: how does it work in re-natal?

hugod19:02:19

@pesterhazy: I’ll take a look. @drapanjanas what does that command actually do, and would doing the same thing work in natal?

drapanjanas19:02:53

well, the command adds a require() for you components to index.*.js files so that these are statically scanned by packager, results are stored in a map. Then the figwheel-bridge.js shims the require which returns the components from that map

pesterhazy19:02:21

ah, that makes sense I guess

drapanjanas19:02:35

that works for sure

drapanjanas19:02:30

but solution depends on figwheel-bridge, natal is implemented differently I guess

drapanjanas19:02:53

same done for images in re-natal. The “images" dir is scanned for images and calls require for all images are added to index.*.js