Fork me on GitHub
#re-frame
<
2016-12-27
>
smnplk00:12:50

Ok I get this part now, so the whole reason for -fx handlers is to keep event (effect) handling function pure and somehow by some magic, I am given the stuff that I need from the outside world in the cofx map.

smnplk00:12:34

So before my handler is ran, re-frame needs to fetch the coeffects that I am interested in, so I need to tell re-frame which are this coeffects, right ?

smnplk00:12:39

Oh, I need to read on :face_with_rolling_eyes:

manenko05:12:35

@gadfly361 @geoffs @mikethompson Thanks guys. I’ll think about it.

mikethompson07:12:23

@smnplk sounds like you are on the right track

owen16:12:32

I cant figure out what the signature for a reg-sub-raw Layer 3 intermediate-node should look like; would it be something like

(reg-sub-raw (register-handler ...) (register-handler ...))
?

andre17:12:03

@owen why do you need reg-sub-raw ?

mikethompson18:12:22

@owen usage:

(reg-sub-raw  
   :an-id 
   some-fn)
So it is like most of the registrations in that way. The raw bit refers to the low level nature of some-fn.
(defn some-fn 
   [app-db event]        ;; app-db is a r/atom not a value
   .... returns a reaction ...)

owen18:12:01

can I return reactions from reg-sub?

owen18:12:11

I want to use :on-dispose

owen18:12:29

I was assuming reg-sub-raw is the way to return a reaction

owen18:12:55

@mikethompson right, but with the intermdiate subscriptions

owen18:12:57

its like:

owen18:12:09

(reg-sub (fn ...) (fn ...))

owen18:12:39

reg-sub-raw takes a different arg signature

mikethompson18:12:53

yep, see above

owen18:12:23

alright lemme mull on this

owen18:12:56

right, the subscribe to external data sources is where I learned of :on-dispose

owen18:12:38

its only because this would be an intermediate subscription that I'm not sure what the signature would look like

owen18:12:18

would I need to drop down to register-handler for this?

mikethompson18:12:18

No, register-handler is the old name for registering event handlers

mikethompson18:12:34

Here. we are in the world of subscription handlers

owen18:12:35

its still in

mikethompson18:12:33

If you want to use :on-dispose ... then you are going to be doing somethng like this:

(reg-sub-raw 
   :some-id
   (fn [app-db event]
       ...... return some reaction in here which has an :on-dispose)

mikethompson18:12:04

Then that can be used like this (subscribe [:some-id])

mikethompson18:12:13

Which is standard

owen18:12:41

right but unless I'm mistaken the some-fn is providing the first argument of app-db which wouldnt work in intermidiate subscriptions

owen19:12:02

instead of app-db its your query-vector

owen19:12:20

and then the second fn takes the dynamic vector: (fn [[todos showing] _]

owen19:12:41

I guess what Im trying to achieve is

owen19:12:29

(reg-sub-raw
  :id: 
  (fn [query-v _]
    [vector of subscriptions])
  (fn [[subscriptions] _]
    (make-reaction
      :on-dispose)))

owen19:12:49

but the 3rd argument doesnt fit reg-sub-raw's signature

mikethompson19:12:56

(reg-sub-raw 
   :some-id 
   (fn [app-db event]
      (make-reaction 
          (fn []  
                use  @app-db or @(subscribe [:some-other] ....)
           :on-dispose  (fn [] ...))))

mikethompson19:12:14

In effect you just use subscribe [:stuff] within the reaction

mikethompson19:12:26

(being sure to put a @ on the front

mikethompson19:12:05

So with reg-sub-raw you do not define the input signals, like reg-sub you just use straight subscriptions within the returned reaction

mikethompson19:12:00

being sure to put @ on the front <--- forgetting this is a trap for newbies everytime

owen19:12:12

ok I think the > with reg-sub-raw you do not define the input signals, like reg-sub makes sense

owen19:12:47

if thats true and reg-sub-raw always takes app-db as an arg though

owen19:12:55

doesnt it re-compute everytime db is changed?

owen19:12:15

so is it less efficient to use rsr or reg-sub?

mikethompson19:12:11

Pretty much the same

owen19:12:06

think I got it

owen19:12:07

thanks man

frank20:12:50

great timing! that new doc was exactly what I needed

manenko20:12:57

yeah, that was the main reason why I’ve choosen reagent+re-frame over other projects: badass documentation.

owen20:12:49

A+ and agreed, docs are this libraries true silver bullet 🙂

qqq21:12:24

My app is re-frame on client side. On server side, I need (1) persistence (kv store) and (2) passing messages between clients in real time. What server setup works nicely with cljs/re-frame on client side?

owen21:12:08

rethink db?

qqq21:12:56

Didn't rethinkdb just shut down?

smnplk21:12:26

I have no experience with couchdb, but I would look into it for something like this @qqq

mikethompson21:12:06

rethinkdb, the commercial entity has closed, but it is likely that rethinkdb the OSS entity will continue on in some form (exact form unknown).

mikethompson21:12:41

@qqq have you considered firebase?

mikethompson21:12:13

I seem to remember the clojurescript library is called matchbox

qqq21:12:16

@mikethompson: would work well as I'm currently using GCP

qqq21:12:33

I'd just like to use whatever fits nicely into the re-frame network, as I have complete power over what tech to use.

mikethompson21:12:15

We used firebase and found it very quick to get going. The data model you get is very limited, and we eventually moved to rethinkdb (which we loved).

qqq21:12:45

@mikethompson: are you using gcp, aws, digital ocean, or your own hosting; and is there a blog post on this somewhere?

mikethompson21:12:47

rethinkdb was a lot more work

mikethompson21:12:37

firebase is hosted

mikethompson21:12:56

Which is part of the reason it is so easy to get going

mikethompson21:12:43

For rethinkdb we used http://compose.io for hosting. Seems a bit too expensive, but we've never bothered to move away

qqq21:12:21

I'm a little squeamish on using http://compose.io ; is there a way to get aws aurora or aws rds to provide the 'real time streaming' part?

qqq21:12:51

@mikethompson : that's what I want! notifications on DB modifications; thanks!