This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-04
Channels
- # admin-announcements (1)
- # alda (2)
- # beginners (52)
- # boot (8)
- # cider (14)
- # cljs-dev (7)
- # cljsrn (5)
- # clojure (4)
- # clojure-belgium (2)
- # clojure-brasil (1)
- # clojure-dev (8)
- # clojure-greece (6)
- # clojure-russia (34)
- # clojure-spec (42)
- # clojurescript (20)
- # cursive (5)
- # funcool (1)
- # hoplon (313)
- # immutant (1)
- # lambdaisland (24)
- # mount (1)
- # om (26)
- # perun (1)
- # planck (2)
- # proton (1)
- # protorepl (6)
- # pure-frame (15)
- # re-frame (14)
- # specter (17)
- # spirituality-ethics (1)
It looks like my subscription handlers are only being passed the subscription vector.
(ns p-frame.db
(:require-macros [reagent.ratom :refer [reaction]])
(:require [reagent.core :as r]
[re-frame.frame :as frame]
[re-frame.router :as router]
[p-frame.handlers :refer [handlers]]))
(def default-db {:name "re-frame"})
(def app-db (r/atom default-db))
(def subscriptions
{:name (fn [& xs] (reaction xs))})
(def ^:private app-frame (frame/make-frame handlers subscriptions))
(defonce ^:private event-queue (router/make-event-queue app-frame app-db))
(def dispatch (partial router/dispatch event-queue app-frame))
(def subscribe (partial frame/subscribe app-frame))
@(subscribe [:name])
;;=> (:name)
Here I register a subscription function that wraps everything it's given in a reaction and returns it, under the key :name
. I'm wondering what the best way to allow access to app-db
for the subscription
Here in the tests, app-db (which is a number)... is simply referenced from inside the subscribe fn: https://github.com/binaryage/pure-frame/blob/master/test/re_frame/test/frame.cljs#L129
any help around how to get the subscription functions passed the app-db atom would be 💯 💯👌:skin-tone-3:
key thing: https://github.com/escherize/p-frame/blob/master/src/cljs/p_frame/db.cljs#L13
@escherize: have you seen this? https://github.com/binaryage/pure-frame/blob/master/src/re_frame/v041_api.cljs#L29-L35
also read comments in my original PR: https://github.com/Day8/re-frame/pull/107#issuecomment-131852982
@darwin: Thanks that's just what I needed. I missed it because (I think) I'm using the 0.5.0-style implementation.