Fork me on GitHub
#re-frame
<
2017-05-04
>
mac12:05:25

I am getting an inexplicable re-frame: no subscription handler registered for: ":test". Returning a nil subscription. even though the :test subscription is registered along with all the other working subscriptions in subs.sljs.

mac13:05:32

@mikethompson Thanks but that is not it. Both (except events is handlers in my setup) are already required in core and all the other subscriptions work.

mikethompson13:05:19

@mac are you somehow registering nil for :test

mikethompson13:05:02

A registration of nil (perhaps overwriting an original, good registration) would look like doesn't exist to re-frame

mac13:05:13

This is what the sub looks like:

(re-frame/reg-sub
 :test
 (fn [db]
   (:test db)))

mikethompson13:05:28

Yep, so: 1. (.log js/console "registration proved") immediately after that registration prints? 2. is there any way that later on ANOTHER registration for :test somehow provides a nil 3. what happens if you change from :test to using :my/test ..

mac13:05:15

1. Prints fine.

mikethompson13:05:48

It obviously looks fine, so there's some underlying assumption that's false - like that the registration happens at all. Just trying to expose the assumption.

mac13:05:02

2. :test occurs nowhere else.

mac13:05:15

3. testing

mac13:05:39

@mikethompson 3. makes no diff. still reports as not registred.

mikethompson13:05:38

Running out of ideas a bit. Put this before the registration (should be nil): (.log js/console "before: " (re-frame.registrar.get-handler :sub :test)) And similar after. Should no longer be nil

mikethompson13:05:02

I'm a bit worried about my code above ... is untested

mac13:05:11

Gives me:

before: null after:   λ[…]λ[db query-vec]λ[db query-vec dyn-vec]jsfunction (db,query_vec,dyn_vec)

mikethompson13:05:53

So nil before and something after

mikethompson13:05:23

Hmm. Are you running clojure

mikethompson13:05:28

Or ClojureScript

mikethompson13:05:02

What happens if you do a @(subscribe [:test]) Immediately after the registration

mikethompson13:05:56

I'm just got this bad feeling about the registration getting overwritten with a nil So I'm trying to see if an immediate subscribe works (whereas one later fails)

mac13:05:44

(.log js/console @(re-frame/subscribe [:my/test])) right after produces null

mac14:05:46

@mikethompson this is very odd

mikethompson14:05:50

Does it produce the same warning

mikethompson14:05:10

re-frame: no subscription handler registered for: ":my/test". Returning a nil

mikethompson14:05:04

Note: the subscription may well return nil ... after all app-db doesn;t contain anything yet

mikethompson14:05:11

So we don't much care what the subscription returns

mikethompson14:05:32

Instead ... we are seeking to see if we see the console warning

mikethompson14:05:43

My guess is that you are not seeing a warning

mac14:05:27

So instead of logging the return value just do @(re-frame/subscribe [:my/test]) ?

mikethompson14:05:56

Logging the value is fine

mikethompson14:05:02

But we don't care about the value

mikethompson14:05:14

All we care about is if you see a warning

mikethompson14:05:29

(about re-frame not finding a subscription handler)

mikethompson14:05:37

I have to go to bed in a min

mikethompson14:05:49

Do you see a warning?

mac14:05:09

If I remove the subscribe from views.cljs I see no output at all from subs, not even the before / after stuff.

mikethompson14:05:09

Are you sure subs.cljs is being required ?

mikethompson14:05:35

The above indicates it is not

mikethompson14:05:17

Gotta go to bed. Good luck

sashton14:05:37

in the two-function version of reg-sub, it appears that the second function doesn’t get a handle on the db. is there a reason for that?

2. (reg-sub
       :a-b-sub
       (fn [q-vec d-vec]
         [(subs/subscribe [:a-sub])
          (subs/subscribe [:b-sub])])
       (fn [[a b] [_]] {:a a :b b}))

mac14:05:06

@mikethompson The issue was caching related 😞 I tried in Firefox and all worked. Now disabled caching in Chrome and works fine again.

curlyfry15:05:15

@sashton I think the reasoning behind it is that the first function is expected to supply the second one with everything it needs

sashton15:05:58

@curlyfry that’s what i ended up doing. but that means i had to write a reg-sub just for the one extra value i needed.

negaduck16:05:42

hello. I’m going to have some panels and some of them should show something by id. How to pass it? Would be cool to have (re-frame/dispatch [:set-active-panel [:card-panel card-id]]), but I’m not sure how to bind id here:

(defn panels [panel-name]
  (case panel-name
    :home-panel [home-panel]
    [:card-panel __card-id__] [card-panel __card_id__]

curlyfry17:05:47

Why isn't card-id a parameter to the fn?

curlyfry17:05:10

Perhaps the card-panel could subscribe to the active id which is set by (dispatch [:set-active-card id]) or something similar?

negaduck17:05:51

@curlyfry, to my taste this would clutter app state. I’m looking into https://github.com/clojure/core.match now. I wonder why it stuck at alpha version.

negaduck17:05:34

it seems like I could just replace case with match in the code above

curlyfry17:05:30

But you'd still have the card id in your app-state, right?

curlyfry17:05:00

Just in the form of a vector of the panel name and id

negaduck17:05:35

@curlyfry, yes, but card-id doesn’t make sense separately when it doesn’t show card-panel

negaduck17:05:24

awesome, cljs.core.match worked

negaduck17:05:34

I still wonder why it stuck at alpha version

Al Baker17:05:04

is there an out of the box example of a little re-frame repl like editor on the left hand side of the screen, results on the right?

scknkkrer20:05:19

how can i combine kioo and re-frame ? Any to-do example ?

gamecubate22:05:45

@negaduck core.match is very interesting. Discovered (by absent-minded me) thanks to you. Begs to be used. Will find an excuse to use it in current project. 🙂

jeffmad22:05:09

Hi all, I am glad to find this channel. We are building a web app for a solar financing company and using re-frame. So far lots of fun.

mac22:05:02

@jeffmad Welcome 🙂