re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
Александр Стоянов 2020-12-02T05:59:01.399300Z

Hello! How can i work with r/atom db in re-frame without this: #<Atom: []> ?

p-himik 2020-12-02T06:23:49.399400Z

Deref them:

(let [a (r/atom 1)]
  ;; Either like this
  @a 
  ;; Or like this
  (deref a))

p-himik 2020-12-02T06:24:10.399600Z

And you shouldn't directly access app-db - you should rely on subscriptions.

Александр Стоянов 2020-12-02T06:30:51.399800Z

That's whole chain: (def records (r/atom [])) --- (rf/reg-sub ::get-data (fn [_] db/records)) --- (def recs (rf/subscribe [::subs/records])) [:p "" @recs]

Александр Стоянов 2020-12-02T06:33:52.400Z

::subs/get-data*

Александр Стоянов 2020-12-02T06:34:43.400200Z

So it comes like #&lt;Atom:[ *data* ]&gt;

p-himik 2020-12-02T06:37:29.400400Z

Derefing a sub returns the value that the sub function returns. Your sub function returns a ratom, so derefing that sub returns that very same ratom. If you want to get the value within the ratom, just deref it inside the sub function. But you shouldn't be using external ratoms in your subs. You either should just directly use ratoms, without any subs, or put the relevant value in the re-frame's app-db via some event.

Александр Стоянов 2020-12-02T06:51:34.400600Z

And if i deref if subs it returns me #<Reaction*some number*: [data]>

Александр Стоянов 2020-12-02T06:51:46.400800Z

in subs*

p-himik 2020-12-02T06:56:52.401Z

If you removed the @ in front of recs then add it back. If you didn't, them I can't really add anything to my previous message. Just don't use regular ratoms in subs.

2020-12-02T09:32:49.402600Z

Hello, i don’t know how to redirect to different SPA, after login. Anyone have an example? Thanks.

2020-12-02T10:43:49.402800Z

Maybe something like

(aset (.-location js/window) "href" url)

2020-12-02T10:43:58.403Z

you can put it in reg-fx

p-himik 2020-12-02T11:01:45.403200Z

Depends on what "different SPA" means exactly. If you mean the same page within the same application, then ideally you would use some routing library like e.g. bidi or reitit that integrate well with HTML5 history. They have all the necessary facilities to redirect from one page to another. If you mean an entirely different app, then the answer above is the correct one. Except that you should not use aset. It should be

(.assign js/location url)
I think.

1👍
2020-12-02T12:22:24.403700Z

thanks!