forked from denistakeda/re-posh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pom.xml | ||
*jar | ||
/lib/ | ||
/classes/ | ||
/out/ | ||
/target/ | ||
.lein-deps-sum | ||
.lein-repl-history | ||
.lein-plugins/ | ||
.repl | ||
.nrepl-port | ||
.cpcache/ | ||
.rebel_readline_history | ||
.clj-kondo/.cache/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-/node_modules/ | ||
-/.clj-kondo/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{:deps {org.clojure/clojure {:mvn/version "1.10.3"} | ||
org.clojure/clojurescript {:mvn/version "1.11.4"} | ||
reagent/reagent {:mvn/version "0.9.0-rc2"} | ||
re-frame/re-frame {:mvn/version "1.0.0"} | ||
re-posh/re-posh {:git/url "https://github.com/jleonard-r7/re-posh.git" | ||
:sha "e5278d39321f7bfbbe575e1085c7412749bf0ea1" | ||
} | ||
cljsjs/react {:mvn/version "16.8.4-0"} | ||
cljsjs/react-dom {:mvn/version "16.8.4-0"} | ||
datascript/datascript {:mvn/version "1.3.8"} | ||
datascript-transit/datascript-transit {:mvn/version "0.3.0"} | ||
clj-commons/secretary {:mvn/version "1.2.4"} | ||
com.rpl/specter {:mvn/version "1.1.3"} | ||
hiccup/hiccup {:mvn/version "2.0.0-alpha2"} | ||
com.bhauman/figwheel-main {:mvn/version "0.2.16"} | ||
com.bhauman/rebel-readline {:mvn/version "0.1.4"} | ||
com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"} | ||
nrepl/nrepl {:mvn/version "0.9.0"} | ||
cider/cider-nrepl {:mvn/version "0.28.2"} | ||
cider/piggieback {:mvn/version "0.5.3"} | ||
re-frame-utils/re-frame-utils {:mvn/version "0.1.0"} | ||
day8.re-frame/re-frame-10x {:mvn/version "0.4.2"} | ||
day8.re-frame/async-flow-fx {:mvn/version "0.3.0"}} | ||
:paths ["src" "target" "resources"] | ||
:aliases {:fig {:extra-paths ["target"]} | ||
:build {:main-opts ["-m" "figwheel.main" "-b" "dev"]} | ||
:repl {:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]} | ||
:rebel {:main-opts ["-m" "rebel-readline.main"]}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
^{:watch-dirs ["src"] | ||
:repl-eval-timeout 1800000} | ||
{:main com.re-posh-minrepro.web-app | ||
:npm-deps false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
;; Figwheel-main configuration options see: https://figwheel.org/config-options | ||
;; these will be overriden by the metadata config options in dev.cljs.edn build file | ||
{ | ||
;; Set the server port https://figwheel.org/config-options#ring-server-options | ||
;; :ring-server-options {:port 9500} | ||
|
||
;; Target directory https://figwheel.org/config-options#target-dir | ||
;; you may want to set this to resources if you are using Leiningen | ||
;; :target-dir "resources" | ||
|
||
;; Server Ring Handler (optional) https://figwheel.org/docs/ring-handler.html | ||
;; If you want to embed a ring handler into the figwheel server, this | ||
;; is for simple ring servers | ||
;; :ring-handler hello_world.server/handler | ||
|
||
;; To be able to open files in your editor from the heads up display | ||
;; you will need to put a script on your path. This script will have | ||
;; to take a file path and a line number ie. | ||
;; in ~/bin/myfile-opener: | ||
;; | ||
;; #! /bin/sh | ||
;; emacsclient -n +$2:$3 $1 | ||
;; | ||
:open-file-command "emacs-opener.sh" | ||
|
||
;; if you are using emacsclient you can just use | ||
;; :open-file-command "emacsclient" | ||
|
||
;; Logging output gets printed to the REPL, if you want to redirect it to a file: | ||
;; :log-file "figwheel-main.log" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(ns com.re-posh-minrepro.db | ||
(:require | ||
[datascript.core :as datascript] | ||
[re-posh.core :as re-posh])) | ||
|
||
(def initial-db | ||
[{:db/ident :timerange | ||
:timerange/timerange {:timerange "24h"}}]) | ||
|
||
(def conn (datascript/create-conn)) | ||
(re-posh/connect! conn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(ns com.re-posh-minrepro.state | ||
(:require | ||
[com.re-posh-minrepro.db :as db] | ||
[re-frame.core :as rf] | ||
[re-posh.core :as rp])) | ||
|
||
(defn init! [] | ||
|
||
;; EVENTS | ||
|
||
(rp/reg-event-ds | ||
::initialize-db | ||
(fn [_ _] | ||
db/initial-db)) | ||
|
||
(rp/reg-event-ds | ||
::set-timerange | ||
[rf/trim-v] | ||
(fn [_ [timerange]] | ||
(js/console.log "setting timerange to: " timerange) | ||
[[:db/add :timerange :timerange/timerange timerange]])) | ||
|
||
;; SUBSCRIPTIONS | ||
|
||
(rp/reg-query-sub | ||
::timerange | ||
'[:find ?t . :where [:timerange :timerange/timerange ?t]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
(ns ^:figwheel-hooks com.re-posh-minrepro.web-app | ||
(:require | ||
[com.re-posh-minrepro.state :as state] | ||
[com.re-posh-minrepro.db :as db] | ||
[datascript.core :as d] | ||
[goog.dom :as gdom] | ||
[goog.string :refer [format]] | ||
[reagent.core :as r] | ||
[reagent.dom :as rdom] | ||
[re-frame.core :as rf])) | ||
|
||
(defn- app [] | ||
(let [i (r/atom 0)] | ||
(fn [] | ||
[:div | ||
(str "current timerange from subscribe: " @(rf/subscribe [::state/timerange])) | ||
[:br] | ||
[:button {:on-click (fn [_] | ||
(swap! i inc) | ||
(rf/dispatch-sync [::state/set-timerange {:timerange (str @i "w")}]))} | ||
"Click Me"] | ||
[:br] | ||
[:br] | ||
(str "current timerange from db(" @i "): " | ||
(d/q '[:find ?t . :where [:timerange :timerange/timerange ?t]] @db/conn))]))) | ||
|
||
(defn- mount-app-element [] | ||
(when-let [el (gdom/getElement "app")] | ||
(rdom/render [app] el))) | ||
|
||
(defn init! [] | ||
(state/init!) | ||
(js/console.debug "dispatching core-state/initialize-db...") | ||
(rf/dispatch-sync [::state/initialize-db]) | ||
(js/console.debug "mounting app element...") | ||
(mount-app-element)) | ||
|
||
(defn ^:after-load on-reload [] | ||
(init!)) | ||
|
||
(defonce init-block | ||
(do | ||
(init!))) |