This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-21
Channels
- # beginners (201)
- # boot (125)
- # cider (3)
- # cljs-dev (21)
- # cljsrn (165)
- # clojars (8)
- # clojure (332)
- # clojure-belgium (1)
- # clojure-gamedev (8)
- # clojure-russia (75)
- # clojure-spec (25)
- # clojure-uk (96)
- # clojurebridge (2)
- # clojurescript (130)
- # code-reviews (16)
- # cursive (26)
- # datomic (20)
- # devops (6)
- # emacs (6)
- # hoplon (90)
- # jobs (9)
- # luminus (2)
- # off-topic (4)
- # om (65)
- # onyx (5)
- # pedestal (4)
- # protorepl (6)
- # re-frame (34)
- # reagent (12)
- # ring (4)
- # ring-swagger (7)
- # specter (2)
- # test-check (8)
- # untangled (2)
- # vim (1)
- # yada (6)
(defn set-input-text! [component k s] (let [refs-m (js->clj (.-refs component) :keywordize-keys true) c (get refs-m k)] (when c (.setNativeProps c (clj->js {:text s}))))) (defn default-on-change-text ([new-text ks] (default-on-change-text new-text ks identity)) ([new-text ks value-f] (default-on-change-text new-text ks value-f nil)) ([new-text ks value-f ref-id] (fn [c] (let [new-value (value-f new-text)] ;set native props (when (keyword? ref-id) (set-input-text! c ref-id new-value)) (om/update-state! c (fn [old-state] (assoc-in old-state ks new-value)))))))
but yea that's the code... using om-next but the only thing you'd have to change is om/update-state! to whatever your favorite library does to change local state
@raspasov use triple backticks before and after string to code-quote
easier than markdown actually, it doesn't even have to be in a new line
@raspasov that snippet's for avoiding input lag, correct?
can you elaborate a bit how that works so I can port it to reagent?
@pesterhazy: I think he is forcing the props to change immediately while waiting for the whole app state to change
@pesterhazy looking at what I did here, I'm not sure it's the best idea, it's a little bit of a lie; I'm directly and mutably setting the native prep (via .SetNativeProps) AND saving the most recent input value into local state
the real reason for that is because I already had the code that was collecting/grabbing from local state
and I didn't want to re-write that when I discovered towards the end that there's no other way to make it lag-free
@levitanong yes and I'm actually NOT driving the value of the input field with local or any state at all
It's definitely better than how I've been doing it.
(text-input {:style text-input-style
:autoCorrect false
:editable false
:maxLength 5
:ref "input-billing-zip"
:onChangeText (fn [new-text] (put! comm-ch (u/default-on-change-text new-text [:form-data ::specs-next/zip])))
:keyboardType "number-pad"
:placeholder "Billing Zip"})
Interesting. You're running a spec to validate the input?
Ah, I was wondering why there was no callback for when the spec complains
you could probably run it on every tap of you wanted to, *probably* won't be an issue but haven't tried it
As a side note: Have you been running into performance issues on om.next? I'm using it too, and it's starting to bog down. :(
Ditto
what generation phones are you targeting? and what specifically are you trying to achieve
Well, navigatorExperimental uses the JavaScript thread so I'm not that surprised
iPad Air
Haha I'm also thinking of switching back to navigatorios
Hmmm lemme check
It uses the A8X chip. Recent generation. Definitely more powerful than the iPhone 5.
our apps runs very smooth on iPhone 6s, 7, reasonable on iPhone 6, and passable on iPhone 5
Have you been using navigatorios, or just navigator?
Ah, well it's pretty performant using those
Navigator animations dropping frames
Not even.
The back is no problem
But I think the fact that a transact is happening plus a large part of the ui is updating is competing with the forward animation
and gave up switching lol (my goal was to try to make the sliding finger as back work with a very native feel)
Placeholder?
No prob
@levitanong have you tried wrapping app-logic parts of callbacks in those?
(def interaction-manager (.-InteractionManager ReactNative))
(defn run-after-interactions [f]
(.runAfterInteractions interaction-manager f))
;or
(defn later [f]
(fn []
(request-animation-frame #(run-after-interactions f))))
@misha yup, I have! Fixes some problems, but not others
also, going forward to a blank
page, and later refreshing it with changes (like slack does upon start up) - helps too
@levitanong so you have something like
(om/set-state! this {;local state performance optimizations
:perf-load-1 false})
Hahaha
(animated-timing-start
(animated-timing
bottom-anim
anim-m)
(fn [_]
;allow loading of cards
(u/log-transact! this `[(~'cards ~(hash-map :f (fn [_] :loading)))
:cards])
(om/update-state! this #(assoc % :perf-load-1 true))))
It's kind of weird though. The big stuff changing isn't even being animated. It's on a different part of the UI
I guess I'll have to try with a timeout first haha
Sounds like a design problem on my part too. Haha
+ this is the exact reason RN animation is done by mutating ui nodes' attributes directly, bypassing lifecycle methods train
That's the tricky thing about iPad. :( so much space
if routing animations happen on the main thread - you share those 16ms you have to run your logic with animation logic
@raspasov Ahh, didn't know that's what it was for. Was only using it to look at FPS
@misha: haha I'm using a real device so I expect it to be really useful
btw @levitanong you're testing all of this with a prod build right?
Dev build
Hahaha
Ok I'll try
Hopeful!
But will perf monitor exist on prod?
will keep you busy fixing "cannot build production because of reasons" errors for a while
Ok thought so haha
Ok this is enough for me to go on.
Awesome :D
Will try not to abuse your hospitality
@levitanong appreciate it, np : )
this one might help too: http://browniefed.com/react-native-animation-book/API.html
@raspasov: oh hey that's great!
Will play with it. Thanks for he heads up!
@misha I like their Animated API a lot too! it's actually just at the right level imo to make great custom animations
@misha yeah animated is pretty cool for custom animations
Anyway, gotta go guys! See ya! Thanks again!
has anyone updated to xcode 8.2.1?
also, has anyone gotten om.next to work with boot-react-native
?
@levitanong Xcode 8.2 right now, I use re-natal, it has worked well