Fork me on GitHub
#fulcro
<
2019-05-31
>
exit213:05:50

@currentoor Interesting, the issue I’m having is the data isn’t being updated to the root form, and the new ident for subform is only being updated. So when I go submit I don’t have updated info in the :listing/by-id for prices, if that makes sense? Is it expected that I grab that info from the subform ident if I want it for my form submit?

daniel.spaniel14:05:02

I have question about testing ... I tried to make a sorta fake component like this in a .cljc test

daniel.spaniel14:05:04

(defsc Person [this props]
  {:query [:db/id :person/name :person/age]
   :ident [:person/by-id :db/id]
   })

(def ui-p (prim/factory Person))

(def p1 (ui-p {:db/id 3}))

daniel.spaniel14:05:45

but when I say (prim/component? p1) I get false in shadowjs test ( but not if i run in the repl ) even though when i js/console.log I see that the object => p1 is a >> $$typeof: Symbol(react.element) <<

daniel.spaniel14:05:15

trying to see if i can do simple fakeish components that run in shadow js testing land

tony.kay15:05:23

if you want to do that @dansudol you’ll have to use something like enzyme

tony.kay15:05:38

I don’t recommend that kind of testing, much, though

tony.kay15:05:18

react elements are what React uses to track things, but there is another internal step where it makes instances, and that’s what you get in this…so libs like enzyme play “fake react” for you

exit215:05:24

Is a subform ident supposed to update its parent form data?

tony.kay15:05:04

Nothing about forms updates your UI. You need to understand how UI refresh works. Your mutations of a form set should be sending follow-on reads for a top-most-field

exit215:05:20

right, so doing set-string! on a subform field, isn’t expected to update the parent forms data that makes up the subform?

exit215:05:42

So I am expected to grab that updated subform data from its ident if I want to use it on the submit of my form? Rather than it being available in the dirty-fields?

tony.kay16:05:48

no, you’re expected to read and understand the documentation. UI gets props. Props follow the rules of the rendering refresh (which is clearly documented). Forms state works on pure data and has no knowledge of your use of mutations or use of UI refresh (again clearly documented and working nested examples provided). If you want complete props, you need to do mutations in the parent to ensure that the parent refreshes, and not just the child. If you want diff work work on the entire form, then it has to be declared a constructed correctly. If you want further help, I’m afraid you’re going to have to sign up for some consulting. This is not the first question you’ve asked that has really clear documentation and instructions. I understand some of this can be confusing, but I’m sorry I cannot be your free tutor 🙂

daniel.spaniel15:05:44

ok .. got it Tony .. i am have methods that use prim/component? to check if is object component and just wanted to check those cases when the thing was component, and sometimes we have to pass component to methods and would be nice if they sorta worked like regular ones ( i can mock out a fake component to respond to all the usual things I suppose ( but trying to be slicker than that .. maybe waste of time .. but ? )

exit216:05:53

When I make a subform, (i.e. :prices (prim/get-query etc..), does the parent form data end up having a reference to the ident of the subform, or does it keep the data the same? I was assuming the parent form data would be updated to :prices [:prices/by-id etc..]

exit218:05:20

I think I’m asking this question a bit weird..

exit218:05:53

Basically I have some data (vector of maps), and I’m iterating over it. (mapv (fn [p] (ui-price (prim/computed p {:edit-mode? listing-edit?}))) prices) In my parent form, I have the query for the subform setup as {:prices (prim/get-query Price)}. But the data of the parent form doesn’t seem to be normalizing the :prices data, it remains as it was before. The sub form that is being iterated over has ident of [:prices/by-id :_id]. This successfully creates this ident but the reference to it in the parent from data doesn’t seem to be happening.