Fork me on GitHub
#re-frame
<
2017-06-03
>
jtth02:06:33

So I have an issue. NEVERMIND. The load/process pattern confused me and I called the process and not the load.

(reg-event-db
  :process-notes-list
  (fn [db [_ response]]
    (-> db
        (assoc :notes-list-answered? true)
        (assoc :notes-list response))))
(reg-event-db
  :load-notes-list
  (fn [db _]
    (GET "/api/list-notes" {:format  :json
                            :handler #(dispatch [:process-notes-list %])})
    db))
Then later, after dispatching :process-notes-list, notes-list is nil. I have similar code doing the same thing with another API endpoint and it’s working fine, and the API works fine in swagger… Any tips?

jtth02:06:48

Corollary: is this load/process dual pattern the normal way? I saw it in the docs.

souenzzo03:06:09

I use this load/process. But I name it fetch/set 🙂

fabrao16:06:09

Hello all, if I want to control the enable state of a button, where do I use it, :component-did-mount or :component-did-update?

pesterhazy18:06:22

[:button {:disabled @enabled?}]

fabrao18:06:44

the problem is that the button state set is inside jQuery object like this

(if (not= "" @(re-frame/subscribe [:item-selecionado]))
          (.enable (aget js/w2ui (str nome "_toolbar")) "print")
          (.disable (aget js/w2ui (str nome "_toolbar")) "print"))

fabrao18:06:25

how to "react" to this?

pesterhazy18:06:07

you're not making things easy for yourself my using react with a third-party (non-react aware) UI toolkit

fabrao19:06:35

So, there is no way to adjust? I thougth we can use any kind of javascript elements

pesterhazy19:06:57

no no, you can do it, but it requires a certain amount of trickery

pesterhazy19:06:11

you'll need to create the external button in the component-did-mount fn (or callback ref)

pesterhazy19:06:51

essentially you want to build a wrapper component

pesterhazy19:06:07

which takes enabled? as a prop

pesterhazy19:06:29

then add a component-will-receive-props method to react to changes to the prop by calling the imperative code

pesterhazy19:06:56

but if you need to do it a lot, you won't enjoy have a pleasant time

pesterhazy19:06:14

better to pick a react-ready (or css-only) toolkit

fabrao19:06:21

Ho, understood

dimovich23:06:30

how can I subscribe to a change in db size?

dimovich23:06:25

I want to update the components only when a new item has been added