Fork me on GitHub
#fulcro
<
2018-10-10
>
aisamu03:10:10

https://clojureverse.org/t/when-is-it-best-not-to-do-a-reagent-spa/2995/2?u=aisamu (That's not me, but I'm not acquainted enough with fulcro to contribute)

claudiu07:10:31

not really fulcro specific, but took a shoot at it since fulcro helps a lot for getting a SPA "right"

👍 8
johnny05:10:17

@tony.kay Thanks! Yes, that was indeed my question. Thought I might be overlooking something.

veddha11:10:41

when i change value textarea, i got an error "Uncaught Error: No protocol method ISwap.-swap! defined for type string: #some markdown"

johnny11:10:27

@veddha.riady You're trying assoc something to a string here. (swap! text assoc :value (-> event .-target .-value))

magra13:10:59

@tony.kay sorry, I wasn't clear. I no longer think that this is related to hanging inspect. I just noticed, that fulcro inspect shows something as a vector that is in afaik a map. form-state adds a key :fulcro.ui.form-state/forms-by-ident to state. fulcro-inspect shows it as

:fulcro.ui.form-state/forms-by-ident
▼
0
▼
:row
#fulcro/tempid["aca264d2-9a9c-473c-98c1-9a2cab9ac3b9"]
:table
:address/by-id
▶
{...}

magra13:10:41

I am just trying to figure out how to use form-state and I am not shure what I am doing wrong. When the db gets cleaned up after successful updates in a working ui fulcro-inspect hangs. I tried using an Address Component and a AddressForm Component as alternatives in an <ul>. A <li> checks whether :fulcro.ui.form-state/config exists. If it exist it calls ui-address-form, else ui-address. Both components query the same data. This all works, optimistic updates, server etc. But as soon as a mutation cleans up and calls (swap! state update-in [:address/by-id 12234] dissoc :fulcro.ui.form-state/config) or maybe fulcro.ui.form-state/delete-from-state* fulcro-inspect stops updating and can not be reloaded but the inspect ui itself stays responsive.

tony.kay13:10:38

The newer versions of inspect use a diff algorithm to transfer db changes to and from the tool (otherwise inspect was getting horribly slow serializing the db every refresh). It is possible that the diff is somehow broken with respect to forms, particularly since they do use a map for an ID. I wonder if @wilkerlucio has any ideas, since he is the primary author of inspect.

tony.kay13:10:44

@magra, you’re saying that the app works fine, it’s inspect that is doing weird things, right?

magra13:10:54

That is one possibility. The other is, that me using two components with the same queries messes something up. But it looks fine to me.

wilkerlucio13:10:33

@magra not sure what you mean by map been displayed as a vector, can you send screenshots? because the data viewer on inspect has no clue about idents or anything, it just projects Clojure data structures, so I wonder how is that displaying

magra13:10:48

Screenshot

magra13:10:15

Screenshot unfolded

magra14:10:24

@wilkerlucio Sorry, forgot to @ you.

wilkerlucio14:10:47

@magra it looks to me that forms-by-ident is a vector, since it's rendering the zero without a link (when it renders maps the keys are clickable for watch), and I guess the contents are ident vectors, correct?

wilkerlucio14:10:25

one thing you can try is logging the app state to the console

wilkerlucio14:10:08

I'm not very famliar with the fucro forms part, but I guess the indexes on the table (`.../form-by-ident`) should be some kind of index instead of positional vectors, right?

wilkerlucio14:10:17

oh, sorry, I just noticed the second SS, that looks odd, my guess is something wrong with some query/normalization

wilkerlucio14:10:08

I would expect the {:row ... :table ...} to be the key of each item in form-by-ident, not part of the content

magra14:10:59

if :state in :config in :reconciler is the correct place to look. Then it is a map.

magra14:10:20

The Map seems to be another notation for ident to prevent clobbering the data at the original location when normalizing.

magra14:10:32

@wilkerlucio Sorry even shorter: my guess is the map notation is used to NOT trigger normalization.

magra15:10:16

@tony.kay I remember there being a chapter in the developers guide that showed how to get to state from the repl. I do not find that anymore. At the moment I look at (:fulcro.ui.form-state/forms-by-ident @(:state (:config (:reconciler @app)))) is that the correct path?

tony.kay15:10:03

@wilkerlucio Forms state uses a map as an ID, FYI

tony.kay15:10:22

the idents like like [:form-table {:row ... :table ...}]

tony.kay15:10:44

it was a way of generating a unique ID for an instance of a form

wilkerlucio15:10:49

yeah, I'm just saying that the state from @magra ss doesn't reflect that, instead if looks like a list of vectors with 2 elements

tony.kay15:10:14

ah, so it does

wilkerlucio15:10:25

and you mean {:form-table {{:row ... :table ...} ...}} right?

tony.kay15:10:42

I don’t remember it that way, no

tony.kay15:10:53

yes, I do mean that as state

tony.kay15:10:58

I meant the other as ident

wilkerlucio15:10:22

ah, ok, makes sense, I was just in a state frame

tony.kay15:10:44

the state looks right to my eye

magra15:10:55

@tony.kay @wilkerlucio That is what I am saying. In inspect it looks like a vector and in @:state of :config of :reconciler in @ I get a map. Am I looking in the right location?

wilkerlucio15:10:00

ah, sorry, you guys are right

wilkerlucio15:10:20

that's probably because of the special case where the key is a complex value, I forgot about that

wilkerlucio15:10:40

in this case you see what you are seeing, map rendering as a seq

wilkerlucio15:10:21

in case, maps are not keyable?

wilkerlucio15:10:40

sorry the confusion

magra15:10:53

No problem 😉 I am just wondering whether this could lock up inspect when removing the link to it.

wilkerlucio15:10:03

about the freezing, if you can reproduce it, can you please check if there are errors hapenning on Inspect?

magra15:10:19

where would I see those errers?

wilkerlucio15:10:26

you can do check that by inspecting the inspect itself (inspect itself is a web page, you can right click an open an inspect for it)

wilkerlucio15:10:01

that will open a secondary chrome inspector inspecting the fulcro inspector (that sounded confusing XD)

magra15:10:53

?? right-click where?

wilkerlucio15:10:01

anywhere in the fulcro inspect

wilkerlucio15:10:05

like if it was a regular web page

magra15:10:54

@wilkerlucio jep! Uncought Error :office/by-id is not ISEQable at main.js:1450

magra15:10:18

@wilkerlucio Thank you for your time, support, and most of all inspect 😉

wilkerlucio15:10:45

thanks man, I like to inspect to not break at all, did you understood what was the problem? I'm trying to figure how we could prevent the case to lock inspect

magra15:10:35

I am not clear. What I know is, when I edit [:item/by-id itemid], form-state does the following: - :item/by-id itemid gets added :fulcro.ui.form-state/config [:fulcro.ui.form-state/forms-by-ident {:row itemid :table :item/by-id}] - :fulcro.ui.form-state/forms-by-ident gets added {{:row itemid :table :item/by-id}{:fulcro.ui.formstate/fields #{fields}, etc}} All this works until editing is finished. Even exchanging the itemid when it was a tempid seems to work. But at the end, to clean up there must be a (dissoc state [:item/by-id itemid] :fulcro.ui.form-state/config) and a (dissoc state [:fulcro.ui.form-state/forms-by-ident] {:row itemid :table item/by-id}) This cleanup causes :item/by-id is not Isequable. I am not clear which part causes this.

wilkerlucio16:10:38

@magra thanks, that sounds like it could be something with the diff state, could you create a small repro with it? so I can try to debug and fix

wilkerlucio15:10:03

thank you very much! I'll take a look on the weekend

magra15:10:55

@wilkerlucio that's what I've got 😉

Daniel Hines22:10:14

Considering the small number of items featured on that radar, I’d say that’s quite significant!

tony.kay19:10:55

Here’s hoping they don’t decide to diss us 😜

😁 36
fulcro 24
🎉 24