This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-11
Channels
- # admin-announcements (71)
- # beginners (8)
- # boot (109)
- # cbus (5)
- # cider (27)
- # cljsrn (77)
- # clojure (65)
- # clojure-austin (5)
- # clojure-berlin (1)
- # clojure-brasil (1)
- # clojure-dev (58)
- # clojure-japan (15)
- # clojure-russia (193)
- # clojure-seattle (3)
- # clojurescript (120)
- # cursive (19)
- # data-science (1)
- # datomic (10)
- # docs (1)
- # editors-rus (17)
- # emacs (2)
- # events (1)
- # funcool (7)
- # hoplon (2)
- # jobs (1)
- # jobs-rus (16)
- # ldnclj (7)
- # leiningen (3)
- # off-topic (12)
- # om (450)
- # onyx (122)
- # re-frame (69)
- # reagent (28)
- # yada (20)
Last CLJS project I did used :cljsbuild and :node-dependencies keys in project.clj but it seems things work differently under Ambly/Natal
js/require does exist and has an effect when invoked but regardless of which module i try to require (and regardless if it's been installed via npm install --save) i get the red screen of death from React saying: "Requiring unknown module 'module-name'. If you are sure the module is there, try restarting the packager." This happens even for the 'react-native' module itself.
@johanatan: You are seeing this require
: https://github.com/facebook/react-native/blob/d3599d0a88b8247ecd3012e3c3e4cb222436feef/packager/react-packager/src/Resolver/polyfills/require.js
When using Ambly / Natal, your have a REPL directly into JavaScriptCore embedded in an iOS app. Since it isn’t Node.js, in order to consider how to use a Node module, you’d have to sort out whether that module’s code can be made to be loadable as a ClojureScript foreign lib, I suppose.
Oh, I had imagined that the React JS itself was also running in a JavaScriptCore. Are you suggesting that it is a different JavaScriptCore?
Then, the blessed React way to include node modules should also work for ClojureScript/Ambly no?
I have no experience using Node modules in React… maybe you could get something to properly load in if you mess with index.ios.js, but I don’t know. (I’m suggesting that you could start down the path of sorting out how to use a Node module with plain React Native…)
Yea, that is well documented. I will try poking around inside index.ios.js. Btw, does it make sense to delete the contents of the render in index.ios.js since we have one in core.cljs which will eventually get called?
I think this is the closest I’ve ever come to the subject: http://blog.fikesfarm.com/posts/2015-07-24-using-react-native-components-in-clojurescript.html
So, I presume that if I create a 'var' holding the required module's exports in index.ios.js, it will be available to the rest of the ClojureScript code?
oh, what do you know, we already have a var React = require('react-native')
in there.
I haven’t tried completely removing the render in index.ios.js. Worth a try. I at least culled it down to being nothing more than returning <View/>
in http://cljsrn.org/ambly.html
If you find improvements, Natal is still a work in progress (all of this stuff is), and perhaps contribute it with a PR
Hmm, unfortunately the React
var created in index.ios.js is not available in ClojureScript/REPL
(It has been hacked together so that it minimally works, but there are tons of things to clean up. )
There’s this (set! js/React (js/require "react-native/Libraries/react-native/react-native.js”))
at thein the awesome-project.core
namespace
It seems like the dependency was loaded but when I try to invoke anything from it, i get this:
testreact.core=> (.alert (.-AlertIOS js/React) "blah" "blahblah")
TypeError: undefined is not an object (evaluating 'React.AlertIOS')
global code (NO_SOURCE_FILE)
testreact.core=>
@johanatan: Your variant also works for me
I coped the set! from here: https://github.com/mfikes/reagent-react-native/blob/master/AwesomeProject/ClojureScript/awesome-project/src/awesome_project/core.cljs
I haven’t tried on latest (>= 0.14) but on earlier versions you can do [:image {:source “path/to.png” :static true}]
@johanatan: Yes. https://gist.github.com/mfikes/89c3e9a705a65e7ce1bb is the relevant bits from the image you can see in this demo https://youtu.be/Ci4uviG8S0o
I'm trying to load an image from my bundle though? Do I need to create a url for that?
This will probably allow me to use the 'uri' path though: https://gist.github.com/icomkid/1004042
@johanatan: That syntax won’t work for my suggestion but :source “filename” does work on earlier versions
does "filename" include any path info? I think React's packager flattens all of the resources to the root though no?
Ahh, I remember seeing something about the names of the images inside the imageset must be particular for React to pick them up
@cldwalker: Did you ever see it work with an imageset?
Yep. But we’re on 0.10. My syntax was off. It’s actually - :source {:isStatic true, :uri “MyIcon"}
hi, can someone please help me with Ambly REPL setup on Cursive?
when I run it though the Lein REPL I can't select the device
running though clojure.main I get error while trying to load the repl:
@mfikes: thanks, I did saw this link before, I'm trying to use the clojure.main approach but when I try to load the lib it can't find it, do you know what can I be doing wrong?
I'm following the tutorial from this page http://cljsrn.org/ambly.html
trying to run with lein repl almost works, except there when I type the device number it just hangs
here are the deps:
I don’t see Ambly in the classpath in that text snippet. Maybe you need to restart Cursive?
@mfikes: right on the spot, restarting IntelliJ did the trick, thank you