pure-frame 2016-06-04

Ahh, the info I was looking for is actually in https://github.com/binaryage/pure-frame/blob/master/test/re_frame/test/frame.cljs I had skimmed it earlier and missed the important bits!!

@ul has joined the channel

@logbot has joined the channel

@ul has left the channel

Now I have a good question:

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

Here's the repo that I've been messing with.

any help around how to get the subscription functions passed the app-db atom would be πŸ’― πŸ’―πŸ‘ŒπŸΌ

@darwin: Thanks that's just what I needed. I missed it because (I think) I'm using the 0.5.0-style implementation.

πŸ‘ 1

@darwin: The next step in my pure-frame odessy is getting dev-cards working. Would you happen to have a reference implementation laying around? πŸ˜„

no, haven’t used it with dev-cards specifically

@escherize has joined the channel

set the channel description: To discuss pure-frame - the re-frame fork

@gadfly361 has joined the channel

I posted in re-frame channel but this channel might be better.

has anyone successfully setup pure-frame? I would like to get devcards working with re-frame I guess I havn't found the docs ( https://github.com/binaryage/pure-frame ) super helpful (edited) So far I have setup a Frame with some handlers and subscriptions [4:34] Star this message

(def frame-handlers
  {:initialize-db
   (fn  [_ _] db/default-db)

   :set-kv
   (fn [db [_ k v]] (assoc db k v))})

(def frame-subs
  {:name (fn [db]
           (reaction (:name @db)))})

(def app-frame (pure-frame/make-frame frame-handlers frame-subs))

app-frame
;;=> #<Frame 2 handlers, 1 subscription | handlers (:initialize-db :set-kv) | subscriptions (:name)>

I figured out how to add more handlers too.

(re-frame/register-event-handler db/app-frame :event-id identity)
;;=> #<Frame 3 handlers, 1 subscription | handlers (:initialize-db :set-kv :event-id) | subscriptions (:name)>

I realized that pure-frame's re-frame.core namespace was included all over - so I stopped that.

now I need to simply build dispatch/subscription functions that work on the app-frame frame...

I think I figured out how to subscribe...

(re-frame.frame/subscribe app-frame [:name])