Fork me on GitHub
#re-frame
<
2019-04-20
>
Bravi15:04:40

hi everyone. I’d like to namespace things in my re-frame db. for example, to have this sort of structure

{:projects {:list []}
 :galleries {:list []}
 :tags {:list []}
and I’m trying to create an interceptor, that will automatically grab a namespace and put things to that namespace. so something like this
(defn namespace-db
  [namespace]
  (rf/->interceptor
   :id :namespace-db
   :before (fn [context]
             (let [db (get-in context [:coeffects :db namespace])]
               (update context :coeffects assoc :db db)))

   :after (fn [context]
            (let [db (get-in context [:coeffetcs :effects :db])]
              (update-in context [:coeffects :effects :db] assoc namespace db)))))
but I think I’m doing something wrong here