Fork me on GitHub
#re-frame
<
2020-03-19
>
rgm01:03:37

@superstructor I see that the new lein-git-inject / github actions flow makes version numbers like v0.2.0 ... these seem to confuse xsc/version-clj underlying olical/depot and lein-ancient:

|                  Dependency |        Current |  Latest |
|-----------------------------+----------------+---------|
|       day8.re-frame/http-fx |         v0.2.0 |   0.1.6 |

superstructor02:03:56

Thanks for the report @U08BW7V1V, thats a bug. I'll fix :thumbsup:

🙏 4
rgm01:03:49

I'd offer a PR to xsc/version-clj but it doesn't look very active

Ivar Refsdal10:03:19

Hi. A question about performance and best practice. Is it OK / decent style to write a general reg-sub like this? Or is there something wrong with this?

(defn db-get [db [_ & [k & [not-found & _]]]]
  (if (vector? k)
    (get-in db k not-found)
    (get db k not-found)))

(reg-sub :db db-get)

(comment
  @(rf/subscribe [:db :datastores/loading?])) ; example usage

Ivar Refsdal11:03:08

Thanks @U2FRKM4TW I'm not sure I agree that sprinkling many reg-subs will help this problem. Perhaps for a bigger code base than mine.

Ivar Refsdal11:03:40

I will think about it a little more though.

Ivar Refsdal12:03:14

Another question. Is there a difference between these two functions:?

(defn view-1
  []
  (let [a (rf/subscribe :a)
        b (rf/subscribe :b)]
    (fn []
      [render-view @a @b])))

(defn view-2
  []
  (let [a @(rf/subscribe :a)
        b @(rf/subscribe :b)]
    [render-view a b]))
Is one style to be preferred?

p-himik12:03:38

In this particular case, there's no perceptible difference. I prefer the second style as the more explicit and terse one.

❤️ 8
Ivar Refsdal12:03:26

Thanks again. When would there be a difference?

p-himik13:03:13

When you call subscribe but don't deref the result in some circumstances. You must always deref the subs, and with view-1 it's possible to make the mistake of not doing that, but it's not possible to do that with view-2.

p-himik13:03:06

Another difference, albeit quite a bit exotic, is when you pass some arguments to view-1 where the top level function uses one set of the arguments and the returned function uses some other set of the arguments. Most of the time, it's an error that results in components not being updated when the data changes.

👍 8