Fork me on GitHub
#fulcro
<
2018-07-03
>
currentoor00:07:46

This form state stuff is really convenient, so glad I don't have to reinvent the wheel here simple_smile

metal 8
Daniel Hines13:07:27

I was really (and perhaps naively) surprised by the variety of runtime errors that cropped up once we released our Angular app into the wild. There seem to be about on the order of 100 different kinds, a few which are true bugs, but the majority are due to old/uncompliant browsers and the like. For those of you running Fulcro in production and logging every runtime error, do you guys see similar things? Or is the Closure Compiler better at catching that sort of thing?

claudiu13:07:52

So far so good for my app. If you mean new features from javascript that not all browsers support "Clojurescript emits ES3 javascript" https://clojureverse.org/t/does-clojurescript-use-or-will-use-new-es6-features-map-set-etc/1986/8?u=claudiu

mitchelkuijpers17:07:21

We only had issues with third party react components which needed polyfills

Daniel Hines12:07:23

Good to hear. Thanks guys

currentoor22:07:33

After editing an entity, using fs/add-form-config*, then if i delete that entity, do i need to clean up the form state? otherwise it will retain that old data right?

currentoor22:07:46

do most of you maintain separate namespace(s) for mutations or co-locate them with the UI components?

wilkerlucio22:07:27

@currentoor I usually co-locate, the proximity of the code is something I care about, like we have a self-contained structure in a component, I like related mutations nearby as well, this is the most common case, but surely there are exceptions

currentoor23:07:09

yeah it's just too bad some mutations depend on the UI tree above the component of interest, like if i have a delete-package mutation and a list of packages elsewhere in the UI

currentoor23:07:43

then i have to put the logic for removing that ident in the mutation, feels like it couples the mutation to more than just the target component

wilkerlucio23:07:44

you can always use declare

currentoor23:07:53

what do you mean?

wilkerlucio23:07:07

clojure declare fn, like (declare MyComponent)

wilkerlucio23:07:23

wait a sec, let me make a bigger example, just have to finish some rice first 😛

currentoor23:07:02

no worries, and thanks for explaining simple_smile

wilkerlucio23:07:49

(declare MyComponent)

(fm/defmutation my-mutation [input]
  (action [env]
    (fp/merge-component! (:reconciler env) MyComponent input)))

(fp/defsc MyComponent [this]
  {:query [:foo :bar]
   :ident [:id :id]})

wilkerlucio23:07:11

you can use declare to reference something that is not available yet, so having the mutation before the component definition is not a problem

currentoor23:07:37

not sure if that would help

currentoor23:07:51

(defmutation delete-package [{:keys [id]}]
  (action [{:keys [state]}]
    (let [ident  [:package/by-id id]
          new-ps (fn [old-ps]
                   (vec (filter #(not= ident %) old-ps)))]
      (swap! state (fn [s]
                    (-> s
                        (dissoc :package)
                        (update :package/by-id dissoc id)
                        (update-in [:packages :tab :table :packages] new-ps)
                        (update ::fs/forms-by-ident dissoc {:table :package/by-id
                                                            :row   id}))))))
  (refresh [env] [:package :packages]))

currentoor23:07:20

i'm saying i don't like how [:packages :tab :table :packages] has to be hard coded in the mutation action

currentoor23:07:34

makes it hard for the same mutation to work in a devcard

currentoor23:07:07

because the main app has several joins to the list of packages, but in a devcard the list of packages is the root

wilkerlucio23:07:18

oh, I use refs a lot to avoid deep nesting

wilkerlucio23:07:35

so I hardly have data with nested maps, they are usually refs that point to something else

wilkerlucio23:07:47

this way, when you transact, you send the ref with it, then is already a target

wilkerlucio23:07:53

makes a lot easier, the data is always near

currentoor23:07:27

do you mean react refs or something else like idents?