This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-30
Channels
- # admin-announcements (4)
- # alda (49)
- # beginners (42)
- # boot (55)
- # cider (33)
- # cljs-dev (4)
- # cljsjs (3)
- # cljsrn (152)
- # clojure (92)
- # clojure-belgium (3)
- # clojure-brasil (18)
- # clojure-dusseldorf (32)
- # clojure-france (2)
- # clojure-greece (10)
- # clojure-japan (1)
- # clojure-mexico (1)
- # clojure-russia (50)
- # clojure-sg (1)
- # clojure-spain (1)
- # clojure-spec (12)
- # clojurescript (262)
- # core-async (2)
- # cursive (7)
- # datomic (79)
- # emacs (16)
- # euroclojure (2)
- # events (1)
- # hoplon (260)
- # jobs (2)
- # jobs-discuss (1)
- # keechma (7)
- # luminus (8)
- # mount (7)
- # off-topic (3)
- # om (101)
- # onyx (33)
- # re-frame (34)
- # reagent (10)
- # slack-help (4)
@kenny: are you starting the dev env using boot dev
? How/where do you call myns.core.main?
guys, anyone have example of PanResponder usage with cljs?
@seantempesta: greetings, did you figure this one out? https://clojurians-log.clojureverse.org/cljsrn/2016-02-14.html
@misha: I think it might have to do with sourcemaps. Did you run re-natal enable-source-maps
?
gentlemen, I sort of found input with custom keyboard and suggests
component:
https://github.com/nulrich/RCTAutoComplete
which is a wrapper around
https://github.com/EddyBorja/MLPAutoCompleteTextField
However I can't get it to actually show any suggests, and the only anomaly I see is very similar to
https://clojurians-log.clojureverse.org/cljsrn/2016-02-14.html
The symptoms are:
1. set breakpoints inside native objective c code, e.g. in
// MLPAutoCompleteTextField.m
- (void)expandAutoCompleteTableViewForNumberOfRows:(NSInteger)numberOfRows
2. start typing into Autocomplete input ==> nothing
3. delete everything in that input ==> breakpoint is hit.note: to make it compile I did:
//node_modules/react-native-autocomplete/RCTAutoComplete.ios.js, line 1
- var React = require('react-native');
+ var React = require('react');
hm, I have this error too https://clojurians-log.clojureverse.org/cljsrn/2016-02-14.html. But app work fine
¯\(ツ)/¯
@savelichalex: @vikeri is right, it is source maps related, has nothing to do with the component above
@savelichalex: how do I do equivalent of this in cljs?
var RCTAutoCompleteApp = React.createClass({
...
onTyping: function (text) {
this.setState({data: ["a", "b", "c"]});
},
...
the this.setState()
partreagent?
@misha, use a private atom bound in a clojure
@pesterhazy: I am using RCTAutoCompleteApp, not writing it
(defn my-handler [e]
(this-as this
(.setState this #js [1 2 3])))
(RCTAutoCompleteApp {:onTyping my-handler})
?you can do something like that yes, though it seems a hacky api on the library author's part
this is with r/atom
hm, understand you)
wait a minute)
you need ref
@savelichalex: I know how to do it, when I am the author of a component. What I need instead – is to be able to call someone else's component's method from my own function which I pass in props
@savelichalex: do you have an example? how does it work? do I assign ref to a component myself, and then use it? how do I access it later?
@sam.roberton: hey, I saw that you contribute some code to boot-react-native. Moving everything to a boot tempdir is a good idea, but it breaks the simple example app. Any idea how I can get around https://github.com/mjmeintjes/boot-react-native/issues/50 ?
@savelichalex: rum
version:
(defn get-ref [state ref-name]
(aget (aget (:rum/react-component state) "refs") ref-name))
(rum/defcs page [state]
(let [pr-ref #(js/console.log (get-ref state "yoyo"))]
(rum/with-ref
(rn/Autocomplete {:onFocus pr-ref, ...})
"yoyo")
@misha: got it) need repo with cheatsheets)
"Waiting for figwheel to load files.." didn't go away so tried manually invoking functions from the repl
future-app.android.core=> (init)
#object[Error Error: schema check failed: {:data (not (sequential? a-object))}]
;; schema of app-db
(def schema {:greeting s/Str
:data [s/Str]})
;; initial state of app-db
(def app-db {:greeting "Hello Clojure in iOS and Android!" :data (into-array (map str (range 1 100)))})
Isn't :data
compatible with what's defined in the schema?idk… in clojure it seems some interop fn, as it returns #object["[Ljava.lang.String;" 0x72c1be38 "[Ljava.lang.String;@72c1be38”]
future-app.android.core=> (into [] (map str (range 1 100)))
["1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "70" "71" "72" "73" "74" "75" "76" "77" "78" "79" "80" "81" "82" "83" "84" "85" "86" "87" "88" "89" "90" "91" "92" "93" "94" "95" "96" "97" "98" "99"]
future-app.android.core=> (into-array (map str (range 1 100)))
#js ["1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "70" "71" "72" "73" "74" "75" "76" "77" "78" "79" "80" "81" "82" "83" "84" "85" "86" "87" "88" "89" "90" "91" "92" "93" "94" "95" "96" "97" "98" "99"]
into-array (into-array aseq)
Returns a new JavaScript array from the elements of aseq.
#js
is a reader tag, it means, read the thing that comes next as a JS array or JS object instead of a vector/map
if you use it in clojurescript code it will output JS with a literal array/object instead of a vector/map
vs if you do this (clj->js [1 2 3])
then the compiled JS will have a clojurescript vector, plus a function call to covert it
hate to plug too shamelessly but I just did a whole screencast on all these things (paywall) https://lambdaisland.com/episodes/clojurescript-interop
long story short: clj-js
and js->clj
will convert recursively between array/object and vector/map
also two tips: avoid using js->clj
on large data structures, it's not designed for that and will not perform well
from a quick google it seems that's a JS error message, not a ClojureScript error message
I think it means Object.keys
is being called with something that isn't a JS object, like a primitive or an array
This doesn't work:
[listview {:style {:paddingLeft 8 :paddingRight 8 :flex 1}
:dataSource (.cloneWithRows (datasource. #js {:rowHasChanged not=}) (clj->js @data))
:renderRow get-row}]])))
But a plain array like ["test"]
instead of @data
worksnot that the literal [1 2 3]
creates a vector, not an array. Important distinction (the latter is mutable)
eponysterical!
do you guys know any project aiming to be a RN-compatible cljs-ajax
-like library? i’m really sad for having to use js/fetch
for this 😞
Let's just fix cljs-ajax, or rn
Surely there just is a bug somewhere in the android code
Have you tried the latest RN?
Maybe a custom back end for cljs-ajax based on fetch?
I thought fetch was a polyfill implemented on top of xhr, in RN at least
idk how’s fetch implemented, but as xhr is already there, it may be an easier starting point (but there’s already limitations: see https://github.com/facebook/react-native/issues/5347 and https://github.com/JulianBirch/cljs-ajax/blob/master/src/ajax/xml_http_request.cljs#L20
future-app.android.core=> (.then (js/window.fetch "") #(println %))
#object[Promise [object Object]]
@debug: are you use (enable-console-print!)
?
hm, you tryied in repl?
println
can sometimes be a little bit flaky in RN in my experience
future-app.android.core=> (.then (js/window.fetch "") #(println %) #(println "rejected" %))`
#object[Promise [object Object]]
That's all I gettry calling console.log directly (and make sure you're tailing the right log)
also try non-https
future-app.android.core=> (.then (js/window.fetch "") #(js/console.log %) #(js/console.log "rejected" %))
#object[Promise [object Object]]
try explicitly setting the method to GET, or POST (to see if you at least get an error)
also use .then
and .catch
instead of passing two args to .then
^^ here's what I use
@pesterhazy: Sorry for the delayed response.. I’m just going to ignore that problem until I figure out how to get the example project working… I am able to run the project and see the app in my emulator, however, if I can the hello world text it does not update in the app. Is there any additional steps I need to do in order to see the app updated?
no, it should work (if you're using boot dev
)
do you see messages about reloading in the debug output?
is this ios or android?
if you reload (shake the device and click reload), does it refresh then?
there's a menu item (hardware?)
I think that option didn't used to exist
I think it was enabled by default
I don't see why not
haven't tried it though
boot-react-native badly needs updating, code and docs
It’s just the example project has a boot.properties with an explicit BOOT_VERSION=2.5.5
yeah maybe it's worth removing that explicit line
yes, extensively
we're relying on it for building our app
I really want to use it but the lack updates and docs make it difficult for someone new to react native. I really don’t want to use re-natal because of leiningen.
I propose to add things to the ticket, I plan to work on brn in the next weeks and to bring it into shape
(-> (js/fetch "") (.then #(js/console.warn %)))
Just noticed, doing that causes a yellow bar to popup on the phone, no console output howeveryeah, React Native takes over console.warn sometimes
@kenny: that's part of what I want to work on
I tried to update to React Native 0.26 but ran into issues unfortunately
I really like BRN's approach of leveraging the RN packager
I really think that re-natal and BRN need to come together. If we are to make a great cljsrn library there needs to not be fragmentation.
Looks like there is discussion about this: https://github.com/drapanjanas/re-natal/issues/53
yeah, I've commented there
need to take some time to understand the pros and cons of brn vs re-natal
but yeah it'd be nice to get more overlap
I guess only the "live dev env" part actually differs, whereas building offline bundles is pretty similar
He's always been helpful and quick to respond
Guys what’s wrong with leiningen? There is smth that I don’t know? Are you have some explanation about boot vs lein?
@savelichalex: There is an inherent problem with declarative DSLs. It is trying to be a build tool by creating an all encompassing DSL, however, the problem is solved much better by just doing things through code: boot.
looks like gulp vs webpack in js world:smile:
boot is particularly well suited for this type of problem: continuously updating files as a result of file watch events
you can also, conceivably, run the backend and frontend in the same boot
instance
I've wasted too much of my life running "npm install"
Has anyone used Rum with boot-react-native? I seem to be having problems getting it to work:
(set! js/React (js/require "react-native/Libraries/react-native/react-native.js"))
(defonce react (js/require "react-native/Libraries/react-native/react-native.js"))
(defn create-element [rn-comp opts & children]
(apply js/React.createElement rn-comp (clj->js opts) children))
(def app-registry (.-AppRegistry react))
(def view (partial create-element (.-View react)))
(def text (partial create-element (.-Text react)))
(defc AppRoot
[state]
(view {:style {:flexDirection "column" :margin 40 :alignItems "center"}}
(text {:style {:fontSize 30 :fontWeight "100" :marginBottom 20 :textAlign "center"}} "CHANGE THIS: HELLO WORLD")))
(defn mount-app [] (support/mount (AppRoot app-state)))
(defonce root-component-factory (support/make-root-component-factory))
(defn ^:export main
[]
(enable-console-print!)
(js/console.log "MAIN")
(.registerComponent (.-AppRegistry react)
“MyApp"
(fn [] root-component-factory))
(mount-app))
The error I’m getting is No protocol method IInterpreter.interpret defined for type object: [object Object]
. This is coming from Sablono not being able to render an object instead of hiccup. It must be able to handle it though because re-natal is able to do it.