rename project

This commit is contained in:
Gered 2016-05-31 10:47:22 -04:00
parent 9e85b571f4
commit 8cc6e69314
22 changed files with 85 additions and 84 deletions

View file

@ -1,15 +1,16 @@
# reagent-data-views
# views.reagent
Reagent components that can subscribe to receive realtime database updates.
[Reagent][1] support for the [views][2] library, allowing Reagent components to
reactively re-render based on server-side changes.
[1]: https://github.com/reagent-project/reagent
[2]: https://github.com/gered/views
### This library is still in the experimental stages! ###
I'm hoping to have a release with documentation and examples soon. For now, tread
carefully when browsing through the code in this repository!
This requires the use of my fork of the [views](https://github.com/gered/views) library
(which is also currently in the experimental stage).
## License
Copyright © 2016 Gered King

View file

@ -1,4 +1,4 @@
# Reagent Data Views Example - Class Registry
# views.reagent Example - Class Registry
This is a "Class Registry" application that has a lot of CRUD operations
in it which allow users to manage students and professors, as well as
@ -15,20 +15,20 @@ using parameters).
Definitely take a look at the [TodoMVC][1] example app before diving into
this and also be sure you're familiar with Reagent.
[1]: https://github.com/gered/reagent-data-views/tree/master/examples/todomvc
[1]: https://github.com/gered/views.reagent/tree/master/examples/todomvc
## Running
### A quick note on the dependencies used
Since Reagent Data Views and the Views library it depends on are all
Since views.reagent and the Views library it depends on are all
currently in somewhat of an experimental / pre-beta state right now,
you will need to first clone the following repositories and manually
install the libraries via `lein install`:
* [views](https://github.com/gered/views)
* [views-sql](https://github.com/gered/views-sql)
* [reagent-data-views](https://github.com/gered/reagent-data-views)
* [views.reagent](https://github.com/gered/views.reagent)
As well, you can install [views-honeysql](https://github.com/gered/views-honeysql)
if you want to try out using HoneySQL instead of SQL with views. But

View file

@ -13,8 +13,8 @@
[gered/clj-browserchannel-immutant-adapter "0.0.3"]
[gered/views "1.5-SNAPSHOT"]
[gered/views-sql "0.1.0-SNAPSHOT"]
[reagent-data-views "0.2.0-SNAPSHOT"]
[reagent-data-views-browserchannel "0.1.0-SNAPSHOT"]
[views.reagent "0.2.0-SNAPSHOT"]
[views.reagent.browserchannel "0.1.0-SNAPSHOT"]
[hiccup "1.0.5"]
[reagent "0.6.0-alpha2"]

View file

@ -4,10 +4,10 @@
[reagent.core :as r]
[ajax.core :refer [POST default-interceptors to-interceptor]]
[net.thegeez.browserchannel.client :as browserchannel]
[reagent-data-views.client.component :refer [view-cursor] :refer-macros [defvc]]
[reagent-data-views.browserchannel.client :as rdv]))
[views.reagent.client.component :refer [view-cursor] :refer-macros [defvc]]
[views.reagent.browserchannel.client :as vr]))
;; Class Registry - Reagent Data Views example app
;; Class Registry - views.reagent example app
;;
;; (This example app is (very) loosely based on one of the examples in the Om tutorial).
;;
@ -350,7 +350,7 @@
"main application container"
[]
[:div.container-fluid
[:h1#app-title.page-header "Class Registry " [:small "Reagent Data Views Example"]]
[:h1#app-title.page-header "Class Registry " [:small "views.reagent Example"]]
[:div.row
[:div.col-sm-6 [people]]
[:div.col-sm-6 [classes]]]])
@ -376,7 +376,7 @@
(defn ^:export run
[]
(rdv/init!)
(browserchannel/connect! {} {:middleware [rdv/middleware]})
(vr/init!)
(browserchannel/connect! {} {:middleware [vr/middleware]})
(r/render-component [class-registry-app] (.getElementById js/document "app")))

View file

@ -16,7 +16,7 @@
[clojure.java.jdbc :as jdbc]
[views.sql.core :refer [vexec! with-view-transaction]]
[views.sql.view :refer [view]]
[reagent-data-views.browserchannel.server :as rdv]))
[views.reagent.browserchannel.server :as vr]))
(def dev? (boolean (env :dev)))
@ -141,7 +141,7 @@
[]
(html5
[:head
[:title "Class Registry"]
[:title "Class Registry - views.reagent Example"]
[:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
(include-css
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
@ -180,7 +180,7 @@
(-> app-routes
(wrap-restful-format :formats [:transit-json])
(wrap-defaults (assoc-in site-defaults [:security :anti-forgery] (not dev?)))
(wrap-browserchannel {} {:middleware [(rdv/->middleware view-system)]})
(wrap-browserchannel {} {:middleware [(vr/->middleware view-system)]})
(wrap-immutant-async-adapter)))
@ -189,7 +189,7 @@
(defn run-server
[]
(rdv/init! view-system {:views views})
(vr/init! view-system {:views views})
(immutant/run handler {:port 8080}))
(defn -main

View file

@ -1,4 +1,4 @@
# Reagent Data Views Example - Todo MVC
# views.reagent Example - Todo MVC
This is a modification of the Todo MVC app for Reagent [demonstrated here][1].
This version of the app has been modified to use a PostgreSQL database
@ -11,14 +11,14 @@ to that data to any number of users currently viewing the app.
### A quick note on the dependencies used
Since Reagent Data Views and the Views library it depends on are all
Since views.reagent and the Views library it depends on are all
currently in somewhat of an experimental / pre-beta state right now,
you will need to first clone the following repositories and manually
install the libraries via `lein install`:
* [views](https://github.com/gered/views)
* [views-sql](https://github.com/gered/views-sql)
* [reagent-data-views](https://github.com/gered/reagent-data-views)
* [views.reagent](https://github.com/gered/views.reagent)
As well, you can install [views-honeysql](https://github.com/gered/views-honeysql)
if you want to try out using HoneySQL instead of SQL with views. But

View file

@ -12,8 +12,8 @@
[gered/clj-browserchannel-immutant-adapter "0.0.3"]
[gered/views "1.5-SNAPSHOT"]
[gered/views-sql "0.1.0-SNAPSHOT"]
[reagent-data-views "0.2.0-SNAPSHOT"]
[reagent-data-views-browserchannel "0.1.0-SNAPSHOT"]
[views.reagent "0.2.0-SNAPSHOT"]
[views.reagent.browserchannel "0.1.0-SNAPSHOT"]
[hiccup "1.0.5"]
[reagent "0.6.0-alpha2"]

View file

@ -3,8 +3,8 @@
[reagent.core :as r]
[ajax.core :refer [POST default-interceptors to-interceptor]]
[net.thegeez.browserchannel.client :as browserchannel]
[reagent-data-views.client.component :refer [view-cursor] :refer-macros [defvc]]
[reagent-data-views.browserchannel.client :as rdv]))
[views.reagent.client.component :refer [view-cursor] :refer-macros [defvc]]
[views.reagent.browserchannel.client :as vr]))
;; Todo MVC - Reagent Implementation
;;
@ -90,7 +90,7 @@
;; Main TODO app component
;;
;; Note that this component is defined using 'defvc' instead of 'defn'. This is a
;; macro provided by reagent-data-views which is required to be used by any Reagent
;; macro provided by views.reagent which is required to be used by any Reagent
;; component that will directly subscribe/unsubscribe to views. It handles all the
;; housekeeping operations that working with views on the client entails.
;;
@ -166,15 +166,15 @@
(defn ^:export run
[]
; Configure reagent-data-views and then BrowserChannel.
(rdv/init!)
; Configure views.reagent and then BrowserChannel.
(vr/init!)
; NOTE: We are passing in an empty map for the BrowserChannel event handlers only
; because this todo app is not using BrowserChannel for any purpose other
; then to provide client/server messaging for reagent-data-views. If we
; then to provide client/server messaging for views.reagent. If we
; wanted to use it for client/server messaging in our application as well,
; we could pass in any event handlers we want here and it would not intefere
; with reagent-data-views.
(browserchannel/connect! {} {:middleware [rdv/middleware]})
; with views.reagent.
(browserchannel/connect! {} {:middleware [vr/middleware]})
(r/render-component [todo-app] (.getElementById js/document "app")))

View file

@ -15,7 +15,7 @@
[clojure.java.jdbc :as jdbc]
[views.sql.core :refer [vexec! with-view-transaction]]
[views.sql.view :refer [view]]
[reagent-data-views.browserchannel.server :as rdv]))
[views.reagent.browserchannel.server :as vr]))
(def dev? (boolean (env :dev)))
@ -30,7 +30,7 @@
;; View system atom
;;
;; We just declare it, don't need to fill it with anything. The call below to
;; reagent-data-views.browserchannel.server/init-views! will take care of it.
;; views.reagent.browserchannel.server/init! will take care of it.
(defonce view-system (atom {}))
@ -124,7 +124,7 @@
[]
(html5
[:head
[:title "todomvc with reagent"]
[:title "TodoMVC - views.reagent Example"]
(include-css "todos.css" "todosanim.css")
(include-js "cljs/app.js")]
[:body
@ -157,11 +157,11 @@
(wrap-defaults (assoc-in site-defaults [:security :anti-forgery] true #_(not dev?)))
; NOTE: We are passing in an empty map for the BrowserChannel event handlers only
; because this todo app is not using BrowserChannel for any purpose other
; then to provide client/server messaging for reagent-data-views. If we
; then to provide client/server messaging for views.reagent. If we
; wanted to use it for client/server messaging in our application as well,
; we could pass in any event handlers we want here and it would not intefere
; with reagent-data-views.
(wrap-browserchannel {} {:middleware [(rdv/->middleware view-system)]})
; with views.reagent.
(wrap-browserchannel {} {:middleware [(vr/->middleware view-system)]})
(wrap-immutant-async-adapter)))
@ -170,14 +170,14 @@
(defn run-server
[]
; init-views! takes care of initialization of views and reagent-data-views at the same
; init! takes care of initialization of views and views.reagent at the same
; time. As a result, we do not need to also call views.core/init! anywhere. The
; same arguments and options you are able to pass to views.core/init! can also be
; passed in here and they will be forwarded along, as this function is intended to be
; a drop-in replacement for views.core/init!.
; if you need to shutdown the views system (e.g. if you're using something like
; Component or Mount), you can just call views.core/shutdown!.
(rdv/init! view-system {:views views})
(vr/init! view-system {:views views})
(immutant/run handler {:port 8080}))

View file

@ -1,6 +1,6 @@
(defproject reagent-data-views-browserchannel "0.1.0-SNAPSHOT"
:description "BrowserChannel client/server support for reagent-data-views."
:url "https://github.com/gered/reagent-data-views"
(defproject views.reagent.browserchannel "0.1.0-SNAPSHOT"
:description "BrowserChannel client/server messaging adapter for views.reagent."
:url "https://github.com/gered/views.reagent"
:license {:name "MIT License"
:url "http://opensource.org/licenses/MIT"}
@ -12,5 +12,5 @@
[org.clojure/clojurescript "1.8.51"]
[reagent "0.6.0-alpha"]
[gered/views "1.5-SNAPSHOT"]
[reagent-data-views "0.2.0-SNAPSHOT"]
[views.reagent "0.2.0-SNAPSHOT"]
[gered/clj-browserchannel "0.3.1"]]}})

View file

@ -1,10 +1,10 @@
(ns reagent-data-views.browserchannel.client
(ns views.reagent.browserchannel.client
(:require
[net.thegeez.browserchannel.client :as browserchannel]
[reagent-data-views.client.core :as client]))
[views.reagent.client.core :as client]))
(defn init!
"performs initial configuration necessary to hook browserchannel into reagent-data-views
"performs initial configuration necessary to hook browserchannel into views.reagent
as the client/server messaging backend. should be called once on page load before
browserchannel is initialized."
[]

View file

@ -1,11 +1,11 @@
(ns reagent-data-views.browserchannel.server
(ns views.reagent.browserchannel.server
(:import
(clojure.lang Atom))
(:require
[clojure.tools.logging :as log]
[net.thegeez.browserchannel.server :as browserchannel]
[views.core :as views]
[reagent-data-views.server.core :as server]))
[views.reagent.server.core :as server]))
(defn- views-send-fn
[client-id [view-sig view-data]]
@ -14,14 +14,14 @@
(defn init!
"initializes the views system and adds browserchannel-specific configuration
to it to enable the necessary hooks into reagent-data-views.
to it to enable the necessary hooks into views.reagent.
this function acts as a direct replacement to calling views.core/init!, so
are able to initialize both views and reagent-data-views by calling this
are able to initialize both views and views.reagent by calling this
function. the arguments and return value are the same as in views.core/init!
so see that function for more information.
one additional option :context-fn can be specified which is a function
that accepts an initial context map created by reagent-data-views and
that accepts an initial context map created by views.reagent and
allows your application to add any information necessary to the context
passed to various view system functions (such as auth-fn, namespace-fn, etc)."
([^Atom view-system options]
@ -34,7 +34,7 @@
(defn ->middleware
"returns clj-browserchannel server-side event middleware for injecting
reagent-data-views handling into the clj-browserchannel client session
views.reagent handling into the clj-browserchannel client session
lifecycle handling. simply include the returned middleware map in your
Ring handler's wrap-browserchannel options."
[^Atom view-system]

View file

@ -1,6 +1,6 @@
(defproject reagent-data-views-sente "0.1.0-SNAPSHOT"
:description "Sente client/server support for reagent-data-views."
:url "https://github.com/gered/reagent-data-views"
(defproject views.reagent.sente "0.1.0-SNAPSHOT"
:description "Sente client/server messaging adapter for views.reagent."
:url "https://github.com/gered/views.reagent"
:license {:name "MIT License"
:url "http://opensource.org/licenses/MIT"}
@ -12,5 +12,5 @@
[org.clojure/clojurescript "1.8.51"]
[reagent "0.6.0-alpha"]
[gered/views "1.5-SNAPSHOT"]
[reagent-data-views "0.2.0-SNAPSHOT"]
[views.reagent "0.2.0-SNAPSHOT"]
[com.taoensso/sente "1.8.1"]]}})

View file

@ -1,6 +1,6 @@
(ns reagent-data-views.sente.client
(ns views.reagent.sente.client
(:require
[reagent-data-views.client.core :as client]
[views.reagent.client.core :as client]
[taoensso.sente :as sente]))
(defonce ^:private send-buffer (atom []))

View file

@ -1,10 +1,10 @@
(ns reagent-data-views.sente.server
(ns views.reagent.sente.server
(:import
(clojure.lang Atom))
(:require
[clojure.tools.logging :as log]
[views.core :as views]
[reagent-data-views.server.core :as server]
[views.reagent.server.core :as server]
[taoensso.sente :as sente]))
(defn- views-send-fn

View file

@ -1,6 +1,6 @@
(defproject reagent-data-views "0.2.0-SNAPSHOT"
:description "Support for Reagent components that get pushed realtime database updates from the server."
:url "https://github.com/gered/reagent-data-views"
(defproject views.reagent "0.2.0-SNAPSHOT"
:description "Reagent support for the views library, allowing Reagent components to reactively re-render based on server-side changes."
:url "https://github.com/gered/views.reagent"
:license {:name "MIT License"
:url "http://opensource.org/licenses/MIT"}

View file

@ -1,4 +1,4 @@
(ns reagent-data-views.client.component)
(ns views.reagent.client.component)
(defmacro defvc
"Defines a Reagent component that works the same as any other defined
@ -30,26 +30,26 @@
(reagent.core/create-class
{:component-will-mount
(fn [this#]
(reagent-data-views.client.component/prepare-for-render! this#))
(views.reagent.client.component/prepare-for-render! this#))
:component-did-mount
(fn [this#]
; invoked immediately after the initial render has occurred.
; we do this here because component-did-mount does not get called
; after the initial render, but will be after all subsequent renders.
(reagent-data-views.client.component/update-subscriptions! this#))
(views.reagent.client.component/update-subscriptions! this#))
:component-will-unmount
(fn [this#]
(reagent-data-views.client.component/unsubscribe-all! this#))
(views.reagent.client.component/unsubscribe-all! this#))
:component-will-receive-props
(fn [this# new-argv#]
(reagent-data-views.client.component/prepare-for-render! this#))
(views.reagent.client.component/prepare-for-render! this#))
:component-did-update
(fn [this# old-argv#]
(reagent-data-views.client.component/update-subscriptions! this#))
(views.reagent.client.component/update-subscriptions! this#))
:component-function
(fn ~args

View file

@ -1,11 +1,11 @@
(ns reagent-data-views.client.component
(ns views.reagent.client.component
(:require
[clojure.set :refer [difference]]
[reagent.core :as r]
[reagent.ratom :refer [RCursor]]
[reagent.impl.component :refer [reagent-component?]]
[reagent-data-views.client.core :as rdv]
[reagent-data-views.client.utils :refer [update-component-state!]]))
[views.reagent.client.core :as rdv]
[views.reagent.client.utils :refer [update-component-state!]]))
(defn unsubscribe-all!
"Unsubscribes a component from all it's current view subscriptions.

View file

@ -1,7 +1,7 @@
(ns reagent-data-views.client.core
(ns views.reagent.client.core
(:require
[reagent.core :as r]
[reagent-data-views.utils :refer [relevant-event?]]))
[views.reagent.utils :refer [relevant-event?]]))
(defonce ^:private first-connection? (atom true))
@ -20,7 +20,7 @@
for the view corresponding with the view-sig.
Generally, for code in a component's render function, you should use
reagent-data-views.client.component/view-cursor instead of using this
views.reagent.client.component/view-cursor instead of using this
function directly. Use of this function instead requires you to manage
view subscription/unsubscription yourself.

View file

@ -1,4 +1,4 @@
(ns reagent-data-views.client.utils
(ns views.reagent.client.utils
(:require
[reagent.core :as r]
[reagent.impl.component :refer [reagent-component?]]))

View file

@ -1,10 +1,10 @@
(ns reagent-data-views.server.core
(ns views.reagent.server.core
(:import
(clojure.lang Atom))
(:require
[clojure.tools.logging :as log]
[views.core :as views]
[reagent-data-views.utils :refer [relevant-event?]]))
[views.reagent.utils :refer [relevant-event?]]))
(defn- handle-subscriptions!
[^Atom view-system client-id view-sig context]
@ -18,7 +18,7 @@
(defn- update-context
[^Atom view-system existing-context]
(if-let [context-fn (get-in @view-system [:reagent-data-views :context-fn])]
(if-let [context-fn (get-in @view-system [:reagent :context-fn])]
(context-fn existing-context)
existing-context))
@ -43,5 +43,5 @@
(defn set-context-fn!
[^Atom view-system f]
(swap! view-system assoc-in [:reagent-data-views :context-fn] f)
(swap! view-system assoc-in [:reagent :context-fn] f)
view-system)

View file

@ -1,4 +1,4 @@
(ns reagent-data-views.utils)
(ns views.reagent.utils)
(defn relevant-event?
[data]