Fork me on GitHub
#reagent
<
2016-09-18
>
yury.solovyov09:09:20

I have a problem setting up reactions in re-frame

yury.solovyov09:09:42

in examples, they seem to de-reference db

yury.solovyov09:09:02

while I have it de-referenced already

yury.solovyov09:09:26

(reg-sub :panel-items (fn [db [_ panel]]
  (println db)
  (reaction (panel db))))

yury.solovyov09:09:35

db is already a map

mikethompson14:09:56

@yury.solovyov version 0.8.0 of re-frame changed subscriptions and I'm sorry that the docs are currently behind.

mikethompson14:09:08

We're working on fixing that

mikethompson14:09:36

In the meantime ... the best source of information is the todomvc example

yury.solovyov14:09:21

I'm about to use plain channels for this

mikethompson14:09:37

BTW, there is also a dedicated re-frame channel

mikethompson14:09:50

The new way of doing things is even simpler than before:

(reg-sub 
  :panel-items 
  (fn [db [_ panel]]
    (println db)
    (panel db)))      ;;   <--- you no longer even need to return a reaction

yury.solovyov14:09:52

yeah, I done that when I started

yury.solovyov14:09:31

but I had a problem that I have to manually trigger change events to update components cause ratom didn't saw changes

mikethompson14:09:01

Hmm. Not sure what is going on there. But the code above is corret

mikethompson14:09:14

Oh wait. Looking at your link

mikethompson14:09:27

Hmm. That code is confusing me. You have your own app-db ?

yury.solovyov14:09:03

I thought I have to

mikethompson14:09:34

re-frame provides app-db

yury.solovyov14:09:42

> From here on in this document, we'll assume app-db is one of these: (def app-db (reagent/atom {})) ;; a Reagent atom, containing a map

yury.solovyov14:09:03

The reference implementation already creates and manages an internal app-db for you, you don't need to declare one yourself.

yury.solovyov14:09:33

ok that explains something

mikethompson14:09:27

Have a look at the two examples

mikethompson14:09:34

As a next step

yury.solovyov14:09:40

yeah, I looked at them. Probably not long enough. What is confusing for me is that it has same names for subs and events

yury.solovyov14:09:24

(reg-event-db
  :time-color 

yury.solovyov14:09:52

isn't :time-color-changed a better name?

mikethompson14:09:26

Sounds quite reasonable

mikethompson14:09:40

I'll change that to remove confusion. Always good to get feedback

yury.solovyov14:09:10

thanks, I was about to give up on reframe and do it with plain reagent to unstuck. Will try again

mikethompson14:09:14

Have a read through the examples and ask on re-frame channel

mikethompson14:09:33

(Although I'm about to go to bed someone else will know over there)