re-frame

Ryan 2023-09-29T18:24:15.832889Z

Hmm, I’m getting the re-frame:subscribe called outside reactive context.. but I’m not using subscribe in an event handler, I’m getting the error while updating an atom.. any clues as to what conditions might cause that?

p-himik 2023-09-29T18:26:32.049079Z

That warning should have a stacktrace that points to the exact location.

Ryan 2023-09-29T18:28:14.038459Z

seems to end in goog.events.handleBrowserEvent … I don’t see an entry in the stack trace that corresponds to any of my code

Ryan 2023-09-29T18:30:17.830749Z

hmmm, I have a popup that has a form backed by an atom.. I bet that popup is connected to an on-click to show the popup.. could that make everything inside that popup be a non-reactive context?

Ryan 2023-09-29T18:36:50.193619Z

Oooooh.. it looks like it might be coming from re-pressed

Ryan 2023-09-29T18:37:25.058399Z

which makes sense at least because it was firing on tabbing between fields on that form which should not itself update the atom!

Ryan 2023-09-29T18:37:27.743879Z

now how to fix

p-himik 2023-09-29T18:41:40.534289Z

I simply wouldn't use re-pressed. It's not that much of useful code, you can write your own keyboard event handling in a handful of lines. IMO there's little need to store current shortcut mappings in app-db, as re-pressed does, unless your app must consider it a part of its state for some reason. In which case, you can always use global interceptors to trigger actual listeners re-assignment.

Ryan 2023-09-29T18:51:30.699799Z

Makes sense, thanks for the advice as always

👍 1
Casey 2023-09-29T18:59:58.618689Z

What are folks using for app-dbs these days? Plain maps, datascript, doxa, re-db, etc? (on new/greenfield prod projects)

2023-10-03T22:55:01.688079Z

From browsing these over time, I think that relic and doxa look the most promising. Note: I've done no deep dive, just browsed. And I probably haven't looked at them all.

🙏 1
p-himik 2023-09-29T19:01:43.294059Z

I use a combination of plain values under some specific keys and a specifically structured nested collection to store normalized data that allows easy updates and queries of the data that I need.

Casey 2023-09-29T19:02:56.298029Z

What are you using for manipulating and querying normalized data?

Casey 2023-09-29T19:03:56.546429Z

That's essentially what I am after. Im working with datasets that aren't huge (~100s of entities) but have lots of internal references

p-himik 2023-09-29T19:04:33.372729Z

A hand-rolled solution that started from subgraph that I've eventually completely rewritten with my own needs in mind. :) Not open-source yet.

p-himik 2023-09-29T19:07:42.507589Z

A few links to related projects, if you're interested. Some of them might or might not be suitable for use with re-frame. • https://github.com/hodur-org/hodur-enginehttps://github.com/den1k/subgraphhttps://github.com/riverford/compound (a supposedly extended and improved version: https://github.com/riverford/compound/tree/compound2) • https://github.com/lilactown/pyramidhttps://github.com/wotbrew/relichttps://github.com/juxt/pull

Casey 2023-09-29T19:18:17.587589Z

Thanks 🙏

Ryan 2023-09-29T21:22:44.451989Z

Next problem of the day: Any clues for preventing input jumping on text input backed by a local atom? Only when editing middle of value, cursor jumps to end. Clues?

p-himik 2023-09-29T21:26:29.179609Z

You are not using :input or :textarea, right?

Ryan 2023-09-29T21:26:46.626679Z

I am using Input

p-himik 2023-09-29T21:27:11.878269Z

What's Input?

Ryan 2023-09-29T21:27:22.219069Z

sorry, :input

p-himik 2023-09-29T21:27:56.603569Z

The thing is, Reagent has hacks for :input and :textarea. If they don't work for you, either you're using some ancient version of Reagent and/or React, or you have some weird stuff going on that prevents those hacks from working.

p-himik 2023-09-29T21:28:20.438399Z

In a plain [:input ...] backed by a local ratom the text cursor shouldn't jump around.

Ryan 2023-09-29T21:29:51.622439Z

Is reagent 1.1.1 ancient?

p-himik 2023-09-29T21:30:17.526179Z

Just tested to be absolutely sure with this:

(defn main-panel []
  (r/with-let [value (r/atom "")]
    [:input {:value     @value
             :on-change #(reset! value (-> % .-target .-value))}]))
No jumping at all. 1.1.1 is not ancient but not the most recent either. The above test was on 1.2.0.

Ryan 2023-09-29T21:30:39.554499Z

Ok awesome, I’ll start by updating, then double checking I’m looking at the write code 🙂

👍 1
Casey 2023-10-01T07:11:20.410409Z

Related? http://day8.github.io/re-frame/FAQs/laggy-input/

p-himik 2023-10-01T07:12:45.125099Z

Shouldn't be - the OP mentions a local atom and jumping of the cursor.

p-himik 2023-10-01T08:46:51.331849Z

Yeah, that's what I meant by that "hack". Since this is built-in, the OP should've seen this behavior already.