This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-16
Channels
- # admin-announcements (44)
- # adventofcode (2)
- # avi (1)
- # beginners (22)
- # boot (328)
- # cider (1)
- # cljs-dev (6)
- # cljsrn (29)
- # clojure (164)
- # clojure-chicago (1)
- # clojure-dev (7)
- # clojure-nl (5)
- # clojure-russia (73)
- # clojure-seattle (1)
- # clojure-turkiye (2)
- # clojured (1)
- # clojurescript (98)
- # core-async (6)
- # cursive (26)
- # datomic (9)
- # editors (5)
- # emacs (41)
- # events (3)
- # garden (2)
- # hoplon (125)
- # ldnclj (18)
- # om (178)
- # omnext (8)
- # onyx (5)
- # parinfer (1)
- # proton (5)
- # re-frame (20)
Hi, I’m working on advanced build for om-next. With help of figwheel-react-native(FRN) we can pretty much use only this during development:
(om/add-root! (om/reconciler {:root-render js/React.render :root-unmount js/React.unmountComponentAtNode})
RootComponent 1)
FRN includes JS file which will call all the needed AppRegister and application initialisation. Question is how to achieve the same for the production build without any help from FRN
Does anyone know how to implement the same but for the om-next?
(defn runProduction []
(.registerRunnable (.-AppRegistry js/React) "figTest"
(fn [params]
(r/render [root] (.-rootTag params)))))
specifically the second argument for the registerrunable
function
@mfikes: Have you tried making production builds with om-next? AppRegister has to be called but I cannot figure out what it wants as a second parameter
btw - finally mystery about root index = 1 resolved:
(.registerRunnable (.-AppRegistry js/React) "RootViewRN"
(fn [params]
(.log js/console “Root tag:" (.-rootTag params)) ;; -> Root tag: 1
Figured it out:
(.registerRunnable (.-AppRegistry js/React)
"RootViewRN"
(fn [params] (om/add-root! (om/reconciler {:root-render js/React.render
:root-unmount js/React.unmountComponentAtNode})
RootViewRN
(.-rootTag params))))
So I have an issue for the Om-Next, but I would like to discuss it here first.
As you may know browser version of React exposes React global which is OK for the browser, but with React-Native they are using package manager so there is actually no reason to use globals anymore as you can always do require(‘react-native’)
The reason why all the RN integration with Om-Next (and Reagent as well actually) has this line:
(set! js/React (js/require "react-native/Libraries/react-native/react-native.js"))
is that Om-Next (coming from the browser) works with React by using global React
variable.
But actually if we go though the Om-Next source code - the only place (apart from om.dom
which has no use on mobile) where React
is used is here:
https://github.com/omcljs/om/blob/master/src/main/om/next.clj#L175
(.apply js/React.Component this# (js-arguments))
https://github.com/omcljs/om/blob/master/src/main/om/next.clj#L186
(set! (.-prototype ~name) (goog.object/clone js/React.Component.prototype))
https://github.com/omcljs/om/blob/master/src/main/om/next.cljs#L303
(js/React.createElement class
I've just tried with following global and everything works just fine:
(set! js/React (js-obj "Component" (js/require "ReactElement")
"createElement" (.-createElement (js/require "ReactElement"))))
If we can make OmNext less depentend on React global, it will make mobile support without ANY hacks which will make the whole thing much more stable in the long run. What do you think?
For the reference - here the gist with working example: https://gist.github.com/artemyarulin/17bf9034ad4712b8edf2So should I create an issue to make those 3 places configurable in Om-Next (like we have for the :render and :unmount already) or it doesn’t worth it?
and to the @mfikes: In your auto-completion example you have to assign react global two times because you forgot to exclude browser react dependency as [[org.omcljs/om "1.0.0-alpha25" :exclusions [cljsjs/react cljsjs/react-dom]]]
and actually related to this - advanced compilation doesn’t work because if you exclude cljsjs/react you also exclude react Closure externs. Just add it… and receive compilation error from the Closure that you cannot override read only react
global because it’s defined in the externs
sry for the wall of text
@artemyarulin: thanks for all this, it's good to see someone digging into these things
@artemyarulin: when I was doing some poking around with react-native and om last week I ran into that problem with advanced compilation as well and one thing that worked for me in the short term was to exclude react and then add my own handwritten React externs file. And in that externs file I made react
no longer read-only
@adamfrey: Thanks, it may work 👍
But I think it may be a better idea to change om-next and remove any need of react
global at the end
@artemyarulin: FWIW https://github.com/dmotz/natal/commit/28136be55e8325f4872e3a2c411b4b3891561b79 (even without the :exclusions
, which is probably worth investigating)
Also, I think David’s keen on tweaks to make this stuff work seamlessly with React Native.
@mfikes: Well, without exclusions my build bundle is 100KB more because it includes browser react which hopefully doesn’t conflict with react native. I guess it should be considered as a good practice to exclude it
I’ll create an issue then in Om, maybe it will an easy task
David response for the reference:
OK but this doesn’t seem very important or hard to work around
`goog.global` exists for a reason
the real fix would be a better import global name story for `:foreign-libs`
that’s about the only thing I would actually consider
so somebody could fix the real root issue and then I would be happy to switch that.
not interested in quick fixes on my side when quick fixes exist downstream
I’ve translated part of the Movies app in the RN repo using the re-natal template. https://github.com/ducky427/movies-cljs-rn
here is a video showing the app: https://youtu.be/ccgMVoaSuD4
@artemyarulin: Dunno if you govareet, but some Russian-language meetup discussing your cross-platform thing: https://www.youtube.com/watch?v=sYPoqHnudNI&t=25m40s
ha, I was presenting it
how cool
Heard many times in Russia - “English is not hard - all the words from C++”