Skip to content

Commit 3e72651

Browse files
committed
0.5.0
1 parent 6904a09 commit 3e72651

File tree

19 files changed

+3092
-247
lines changed

19 files changed

+3092
-247
lines changed

README.md

Lines changed: 84 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -2,121 +2,134 @@
22

33
Visualize [re-frame](https://github.com/Day8/re-frame) pattern data or [reagent](https://reagent-project.github.io) ratom data as a tree structure, watch re-frame events and export state.
44

5-
<img src="img/re-frisk-debugger.gif">
5+
<img src="img/re-frisk.png">
66

7-
## Changes
7+
## Support re-frisk
88

9-
### 0.4.5
10-
- Implemented app-db-sorted
9+
If re-frisk makes your work with re-frame applications easier and you like it please take a moment and support it:
1110

12-
### 0.4.4
13-
14-
- Remote debugger for react native and electron
15-
- app-db cljs live filter
16-
- сompatibility with previous versions of re-frame
11+
💎BTC: 3K37vEEyBsKSat2rS74CXUA3LnVR9QPztD
1712

13+
💎ETH: 0x612E124d922a6DE46953226965C8e773166891E9
1814

1915
## Usage
2016

21-
### Web applications with re-frame
17+
### Web application
2218

2319
In-app re-frisk debugger. The debugger will be embedded into the interface of your application.
2420

2521
[![Clojars](https://img.shields.io/clojars/v/re-frisk.svg)](https://clojars.org/re-frisk)
2622

27-
1. Add `[re-frisk "0.4.5"]` to the dev `:dependencies` in your project.clj
28-
29-
2. Run re-frisk using `enable-re-frisk!` function
30-
31-
```clojure
32-
(:require [re-frisk.core :refer [enable-re-frisk!]])
33-
34-
(defn ^:export run
35-
[]
36-
(dispatch-sync [:initialize])
37-
(enable-re-frisk!)
38-
(reagent/render [simple-example]
39-
(js/document.getElementById "app")))
40-
```
41-
42-
This is just an example, it's better to enable re-frisk in the dev environment
43-
23+
1. Add re-frisk as a dev dependency by placing `[re-frisk "0.5.0"]` within `:profiles :dev :dependencies`. For example:
24+
25+
```cljs
26+
:profiles
27+
{:dev
28+
{:dependencies [[some-other-package "0.0.0"]
29+
[re-frisk "0.5.0"]] }}
30+
```
31+
32+
2. Locate the `:compiler` map under `:dev` and add:
33+
34+
`:preloads [re-frisk.preload]`
35+
36+
For example:
37+
38+
```cljs
39+
{:builds
40+
[{:id "dev"
41+
:source-paths ["src" "dev"]
42+
:compiler {...
43+
:preloads [re-frisk.preload]}}]}
44+
```
45+
4446
ENJOY!
4547

46-
### React native, Electron and Web applications with re-frame using remote server
48+
### React native, Electron and Web applications using re-frisk remote server
4749

48-
Run remote re-frisk debugger server using leiningen re-frisk [plugin](https://github.com/flexsurfer/lein-re-frisk) by following next steps:
50+
Run remote re-frisk debugger server using leiningen re-frisk [plugin](https://github.com/flexsurfer/lein-re-frisk) following next steps:
4951

50-
1. Add `[lein-re-frisk "0.4.8"]` into your global Leiningen config (`~/.lein/profiles.clj`) like so:
52+
1. Add `[lein-re-frisk "0.5.0"]` into your global Leiningen config (`~/.lein/profiles.clj`) like so:
5153

52-
```clojure
53-
{:user {:plugins [[lein-re-frisk "0.4.8"]]}}
54-
```
55-
56-
or into the `:plugins` vector of your project.clj
57-
58-
```clojure
59-
(defproject your-project "0.1.1"
60-
{:plugins [[lein-re-frisk "0.4.8"]]})
61-
```
54+
```cljs
55+
{:user {:plugins [[lein-re-frisk "0.5.0"]]}}
56+
```
57+
58+
or into the `:plugins` vector of your project.clj
59+
60+
```cljs
61+
(defproject your-project "0.1.1"
62+
{:plugins [[lein-re-frisk "0.5.0"]]})
63+
```
6264

6365
2. Start a web server in the current directory on the default port (4567):
6466

65-
$ lein re-frisk
67+
`$ lein re-frisk`
6668

67-
Or select a different port by supplying the port number on the command line:
69+
Or select a different port by supplying the port number on the command line:
6870

69-
$ lein re-frisk 8095
71+
`$ lein re-frisk 8095`
7072

7173

72-
3. Add `[re-frisk-remote "0.4.2"]` to the dev `:dependencies` in your project.clj
74+
3. Add `[re-frisk-remote "0.5.0"]` to the dev `:dependencies` in your project.clj
7375

74-
run re-frisk using `enable-re-frisk-remote!` function on the localhost and default port (4567)
76+
run re-frisk using `enable-re-frisk-remote!` function on the localhost and default port (4567)
77+
78+
```cljs
79+
(:require [re-frisk-remote.core :refer [enable-re-frisk-remote!]])
80+
81+
(enable-re-frisk-remote!)
82+
```
83+
84+
Or select a different host and port by supplying the host and port number:
85+
86+
```cljs
87+
(enable-re-frisk-remote! {:host "192.168.1.1:8095"})
88+
```
89+
90+
This is just an example, it's better to enable re-frisk in the dev environment
7591

76-
```clojure
77-
(:require [re-frisk-remote.core :refer [enable-re-frisk-remote!]])
92+
Run an application
7893

79-
(defn ^:export run
80-
[]
81-
(dispatch-sync [:initialize])
82-
(enable-re-frisk-remote!)
83-
(reagent/render [simple-example]
84-
(js/document.getElementById "app")))
85-
```
94+
ENJOY!
8695

87-
Or select a different host and port by supplying the host and port number:
96+
See also [Using re-frisk with re-natal](https://github.com/flexsurfer/re-frisk/wiki/Using-re-frisk-with-re-natal)
8897

89-
```clojure
90-
(enable-re-frisk-remote! {:host "192.168.1.1:8095"})
91-
```
98+
### Settings
9299

93-
This is just an example, it's better to enable re-frisk in the dev environment
100+
You can provide starting position for the re-frisk panel
94101

95-
Run an application
102+
```cljs
103+
(enable-re-frisk! {:x 100 :y 500})
96104

97-
ENJOY!
105+
(enable-frisk! {:x 100 :y 500})
106+
```
98107

99-
See also [Using re-frisk with re-natal](https://github.com/flexsurfer/re-frisk/wiki/Using-re-frisk-with-re-natal)
108+
also, it will be helpful for the IE, because it doesn't support resize property, you can provide width and height
100109

101-
### re-frame handlers
110+
```cljs
111+
(enable-re-frisk! {:width "400px" :height "400px"})
112+
113+
(enable-frisk! {:width "400px" :height "400px"})
114+
```
102115

103-
You can also watch all re-frame subscriptions and events
116+
You can provide external window dimensions
104117

105-
```clojure
106-
(enable-re-frisk! {:kind->id->handler? true})
118+
```cljs
119+
(enable-re-frisk! {:ext_height 1000 :ext_width 1200})
107120
```
108121

109122
### Events
110123

111124
If you don't want to watch events you can turn it off providing settings `{:events? false}`
112125

113-
```clojure
126+
```cljs
114127
(enable-re-frisk! {:events? false})
115128
```
116129

117130
Also you can watch interceptor's context providing `re-frisk.core/watch-context` in the reg-event interceptors list
118131

119-
```clojure
132+
```cljs
120133
(reg-event-db
121134
:timer-db
122135
[re-frisk.core/watch-context]
@@ -136,65 +149,22 @@ Export works only for the cljs [data structures](https://github.com/cognitect/tr
136149
[<img src="https://docs.google.com/drawings/d/1ptKAIPfb_gtwwSqYmt-JGTkwPVm_6LeWjjm-FcWznBs/pub?w=1786&amp;h=916">](
137150
https://docs.google.com/drawings/d/1ptKAIPfb_gtwwSqYmt-JGTkwPVm_6LeWjjm-FcWznBs/edit?usp=sharing)
138151

139-
### Settings
140-
141-
You can provide starting position for the re-frisk panel
142-
143-
```clojure
144-
(enable-re-frisk! {:x 100 :y 500})
145-
146-
(enable-frisk! {:x 100 :y 500})
147-
```
148-
149-
also, it will be helpful for the IE, because it doesn't support resize property, you can provide width and height
150-
151-
```clojure
152-
(enable-re-frisk! {:width "400px" :height "400px"})
153-
154-
(enable-frisk! {:width "400px" :height "400px"})
155-
```
156152

157153
### reagent
158154
If you are not using re-frame in your app, you can run re-frisk without re-frame by `enable-frisk!` function
159155

160-
```clojure
156+
```cljs
161157
(enable-frisk!)
162158
```
163159

164160
If you want to watch ratom or log any data, you can add it using `add-data` or `add-in-data` functions
165161

166-
```clojure
162+
```cljs
167163
(add-data :data-key your-data)
168164

169165
(add-in-data [:data-key1 :data-key2] your-data)
170166
```
171167

172-
## Advanced thing
173-
174-
For me, it's very handy to name events with the appropriate suffix, for example for reg-event-db :event-key-db, and for reg-event-fx :event-key-fx, in that case re-frisk automatically highlight these events
175-
176-
Also you can watch all re-frame views which are rendering now
177-
178-
Add `:external-config {:re-frisk {:enabled true}}}}` to the dev `:compiler` in your project.clj if you are working with the re-frame app
179-
180-
<img src="img/re-frisk-project.png">
181-
182-
this config needed to do not generate any code in production.
183-
184-
185-
Require macro
186-
```clojure
187-
(:require [re-frisk.core :refer-macros [def-view]])
188-
```
189-
190-
Define your views (components) with the `def-view` macro
191-
192-
```clojure
193-
(def-view greeting
194-
[message]
195-
[:h1 message])
196-
```
197-
198168

199169
### For more
200170

@@ -206,10 +176,9 @@ reagent [dev/re_frisk/reagent_demo.cljs](https://github.com/flexsurfer/re-frisk/
206176
Works weird in the Internet Explorer which doesn't support css resize property.
207177
Debugger doesn't work in IE.
208178

209-
If you are using `reagent.core/create-class` function for creating views, data for these views will be still showing in the re-frisk after this components will be unmounted.
210179

211180
## License
212181

213-
Copyright © 2016-2017 Shovkoplyas Andrey [motor4ik]
182+
Copyright © 2016-2017 Andrey Shovkoplyas [andre]
214183

215184
Distributed under the MIT License (MIT)

dev/re_frisk/demo.cljs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
(def initial-state
2222
{:timer (js/Date.)
23+
:form1 true
2324
:jsobj js/setInterval
2425
:time-color "#f88"
2526
:clock? true})
@@ -59,6 +60,12 @@
5960
;; new value
6061
[{db :db} [_ value]]
6162
{:db (assoc db :clock? value)}))
63+
64+
(reg-event-db
65+
::change-form
66+
(fn [db _]
67+
(update db :form1 not)))
68+
6269
;; -- Subscription Handlers ---------------------------------------------------
6370

6471

@@ -68,6 +75,12 @@
6875
[db _] ;; db is the value currently in the app-db atom
6976
(:timer db)))
7077

78+
(reg-sub
79+
:form1?
80+
(fn
81+
[db _] ;; db is the value currently in the app-db atom
82+
(:form1 db)))
83+
7184

7285
(reg-sub
7386
:time-color
@@ -115,17 +128,30 @@
115128
:value @time-color
116129
:on-change #(dispatch [:time-color (-> % .-target .-value)])}]])))
117130

131+
(defn form1 []
132+
(fn []
133+
(let [clock? (rf/subscribe [:clock?])]
134+
[:div
135+
[greeting "Hello world, it is now"]
136+
(when @clock? [clock])
137+
[color-input]])))
138+
139+
(defn form2 []
140+
(fn []
141+
[:div "form2"]))
142+
118143
(def-view simple-example
119144
[]
120145
(reagent/create-class
121146
{
122147
:reagent-render (fn []
123-
(let [clock? (rf/subscribe [:clock?])]
148+
(let [form1? (subscribe [:form1?])]
124149
[:div
125-
[greeting "Hello world, it is now"]
126-
(when @clock? [clock])
127-
[color-input]]))}))
128-
150+
(if @form1?
151+
[form1]
152+
[form2])
153+
[:div]
154+
[:div {:on-click #(dispatch [::change-form])} "change form"]]))}))
129155
(defn mount []
130156
(reagent/render [simple-example]
131157
(js/document.getElementById "app")))
@@ -138,6 +164,5 @@
138164
(defn ^:export run
139165
[]
140166
(dispatch-sync [:initialize-db])
141-
(enable-re-frisk! {:kind->id->handler? true})
142167
(mount))
143168

img/re-frisk-debugger.gif

-1.66 MB
Binary file not shown.

img/re-frisk.png

97.5 KB
Loading

project.clj

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
(defproject re-frisk "0.4.5"
1+
(defproject re-frisk "0.5.0"
22
:description "Visualize re-frame pattern data in your re-frame apps as a tree structure."
33
:url "https://github.com/flexsurfer/re-frisk"
44
:license {:name "MIT"
55
:url "https://opensource.org/licenses/MIT"}
66

77
:min-lein-version "2.6.1"
88

9-
:dependencies [[org.clojure/clojure "1.8.0"]
10-
[org.clojure/clojurescript "1.9.89"]
11-
[reagent "0.6.0"]
12-
[re-frame "0.8.0"]
13-
[re-frisk-shell "0.4.5"]
9+
:dependencies [[org.clojure/clojure "1.9.0-alpha17"]
10+
[org.clojure/clojurescript "1.9.671"]
11+
[reagent "0.7.0"]
12+
[re-frame "0.10.1"]
13+
[re-frisk-shell "0.5.0"]
1414
[com.cognitect/transit-cljs "0.8.239"]]
1515

16-
:plugins [[lein-cljsbuild "1.1.5" :exclusions [[org.clojure/clojure]]]
17-
[lein-figwheel "0.5.9"]]
16+
:plugins [[lein-cljsbuild "1.1.7" :exclusions [[org.clojure/clojure]]]
17+
[lein-figwheel "0.5.13"]]
1818

1919
:source-paths ["src"]
2020

@@ -30,7 +30,8 @@
3030
:output-to "resources/re-frisk/js/compiled/re_frisk.js"
3131
:output-dir "resources/re-frisk/js/compiled/out/re-frisk"
3232
:source-map-timestamp true
33-
:preloads [devtools.preload]
33+
:preloads [devtools.preload
34+
re-frisk.preload]
3435
:external-config {:re-frisk {:enabled true}}}}
3536
{:id "reagent"
3637
:source-paths ["src" "dev"]

0 commit comments

Comments
 (0)