This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-12
Channels
- # aleph (1)
- # announcements (1)
- # beginners (54)
- # calva (11)
- # clojure (55)
- # clojure-france (1)
- # clojure-italy (4)
- # clojure-spec (10)
- # clojure-uk (7)
- # clojurescript (3)
- # cursive (3)
- # data-science (8)
- # datomic (10)
- # emacs (1)
- # fulcro (21)
- # graalvm (2)
- # jobs (1)
- # kaocha (1)
- # nrepl (1)
- # nyc (1)
- # other-languages (5)
- # reitit (8)
- # rum (5)
- # shadow-cljs (84)
- # spacemacs (2)
- # sql (20)
- # testing (3)
- # vim (1)
How do you catch a global keypress event? (:onKeyDown). I can catch on an input or a button that has the focus. I tried on the (nearly) outermost div
but no response. I'm asking because setting up css refresh (which will be via a mutation that changes the :react-key
on inj/style-element
).
I do write components that specific for it, and those components use componentDidMount and componentWillUnmount to attach and dettach events, then you use something like: (key-handler {::key "s" ::action (fn ...)}
I know that there's an event whenever you alter the source code that I can use, the ^:dev/after-load refresh
function. But now that I've asked, I'm curious about global keymappings...
React Native helper library update: I added trial support for component co-located styles, which is implemented purely in the factory. See the bottom of the README for the idea. Interested in feedback/improvements, but I am finding it useful so far: https://github.com/fulcrologic/fulcro-native#react-factory With a bit more work we can make a macro version that would let us do the DOM-like thing: make the props optional, and let the keyword stand outside…be a nice parallel:
;; We're not quite here yet, but this would be nice:
(native/ui-button :.local-style "Hello world")
So far I’ve not been impressed by native’s built-in StyleSheet.create, but it probably does some optimizations someone will want…either that or I’ll be really disappointed
well, disappointment it is. All StyleSheet.create
does is some validation and makes it immutable.
https://github.com/facebook/react-native/blob/91f139b94118fe8db29728ea8ad855fc4a13f743/Libraries/StyleSheet/StyleSheet.js#L349
So, I think I already like mine better. 😜
I am porting an app from fulcro 2 to 3. So from legacy router to the new dynamic router. I want to trigger a load on changing a route. But I want to route immediately, not defer, because in most cases there will already be data in the db, the load is there in case something changed on the server. If I call load in will-enter, before calling route-immediate it gets called thrice (and the manual warned against this). What is an idiomatic way to route immediately and issue a load? Do I trigger it in Component will mount? (The manual warns against that too ;-))
@magra So, staying on the legacy router is fine if you’ve already written to it. It will work better with SSR if you do and SSR.
but, with regard to your actual question: If you need to do a load in will-enter
, you use route-deferred
. It is ok to use :componentDidMount
, but just beware that there are reasons for a component to re-mount that may not coincide with your data’s lifecycle.
will-enter
probably makes more sense, and calling a mutation from there that checks app state, optionally issues the load, and also triggers the route change is what I’d recommend.
:will-enter (fn [app _] (dr/route-deferred the-target (fn [] (comp/transact! this [(ensure-loaded)])))
you could also put the target ready into that tx, if you want, or in the body of the mutation itself