Fork me on GitHub

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).


React issue…I would think outermost div would do it.


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: 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. 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.


Is there a way to get route-deferred to signal target-ready before :post-mutation?


: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


ok! Thank you!!!!


Ah. Would it work to call target-ready and then route-deferred with route-deferred never calling target-ready?


will-enter has to return one or the other…they do not side effect


oh, I see you question…no, that would not work


target-ready looks for a previously registered ident


which the return of deferred registers


I see. Thank you!!!