Skip to content

Commit c6746f0

Browse files
committed
In this version, Si-frame uses Signaali directly.
1 parent c786cc1 commit c6746f0

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

README.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
This project is a fork of [Re-frame `v1.4.3`](https://github.com/day8/re-frame/tree/v1.4.3) where
88
the reactivity is implemented using [Signaali](https://github.com/metosin/signaali)
9-
via [Siagent](https://github.com/metosin/siagent) instead of [Reagent](https://github.com/reagent-project/reagent).
9+
without [Reagent](https://github.com/reagent-project/reagent).
1010

1111
It was created:
1212
- to battle-proof Signaali's API before its release,
@@ -27,7 +27,7 @@ Project status: [experimental](https://github.com/metosin/open-source/blob/main/
2727
The namespaces were not modified, keep using it as if it was the original Re-frame project.
2828

2929
What's different in the library:
30-
- Reagent was replaced by Siagent.
30+
- Reagent was removed.
3131
- Some small changes were needed in `re-frame.interop` to making it work with Signaali.
3232
- `re-frame.interop/after-render` won't work exactly in the same way, but most apps don't use it.
3333

@@ -36,12 +36,10 @@ What's different in the library:
3636
In your `deps.edn`, replace the re-frame dependencies with:
3737

3838
```clojure
39-
fi.metosin/si-frame {:mvn/version "1.4.3.0"}
39+
fi.metosin/si-frame {:mvn/version "1.4.3.0-no-siagent"}
4040
```
4141

42-
This lib should work for you if:
43-
- All the Reagent features your Reagent components (if any) are using are supported by [Siagent](https://github.com/metosin/siagent).
44-
- Your codebase is not directly using the low level implementation of Reagent, e.g. the `reagent.ratom/RAtom` type.
42+
This lib should work for you if you don't use Reagent in your code base.
4543

4644
## UIx interop
4745

deps.edn

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:scope "provided"}
88
org.clojure/clojurescript {:mvn/version "1.10.844"
99
:scope "provided"}
10-
fi.metosin/siagent {:mvn/version "0.1.0"}
10+
fi.metosin/signaali {:mvn/version "0.1.0"}
1111
net.cgrand/macrovich {:mvn/version "0.2.1"}
1212
org.clojure/tools.logging {:mvn/version "1.1.0"}}
1313

@@ -19,7 +19,7 @@
1919
:exec-args {:sync-pom true
2020
:group-id "fi.metosin"
2121
:artifact-id "si-frame"
22-
:version "1.4.3.0"
22+
:version "1.4.3.0-no-siagent"
2323
:jar "si-frame.jar"}}
2424

2525
;; clojure -X:deploy

src/re_frame/flow/alpha.cljc

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[re-frame.loggers :refer [console]]
77
[re-frame.interceptor :refer [->interceptor get-effect get-coeffect assoc-effect]]
88
[re-frame.interop :as interop]
9-
#?(:cljs [reagent.core :as r])))
9+
[signaali.reactive :as sr]))
1010

1111
(def db-path? vector?)
1212

@@ -94,7 +94,7 @@
9494
(merge
9595
{::new? true}
9696
#?(:cljs
97-
{::ref (r/reaction (get-in @db/app-db (:path m)))}))))))
97+
{::ref (sr/create-memo (fn [] (get-in @db/app-db (:path m))))}))))))
9898

9999
(defn clear-flow
100100
([]

src/re_frame/interop.cljs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
(ns re-frame.interop
22
(:require [goog.async.nextTick]
33
[goog.events :as events]
4-
[reagent.core]
5-
[reagent.ratom]
64
[signaali.reactive :as sr]))
75

86
(defn on-load
97
[listener]
10-
;; events/listen throws an exception in react-native environments because addEventListener is not available.
118
(try
129
(events/listen js/self "load" listener)
1310
(catch :default _)))
@@ -25,7 +22,7 @@
2522
(def ^boolean debug-enabled? "@define {boolean}" ^boolean goog/DEBUG)
2623

2724
(defn ratom [x]
28-
(reagent.core/atom x))
25+
(sr/create-state x {:propagation-filter-fn not=}))
2926

3027
(defn ratom? [x]
3128
;; ^:js suppresses externs inference warnings by forcing the compiler to
@@ -38,13 +35,13 @@
3835
(satisfies? IDeref x))
3936

4037
(defn make-reaction [f]
41-
(reagent.ratom/make-reaction f))
38+
(sr/create-memo f {:propagation-filter-fn not=}))
4239

4340
(defn add-on-dispose! [a-ratom f]
44-
(reagent.ratom/add-on-dispose! a-ratom f))
41+
(sr/add-on-dispose-callback a-ratom f))
4542

4643
(defn dispose! [a-ratom]
47-
(reagent.ratom/dispose! a-ratom))
44+
(sr/dispose a-ratom))
4845

4946
(defn set-timeout! [f ms]
5047
(js/setTimeout f ms))
@@ -72,4 +69,4 @@
7269

7370
(defn reactive?
7471
[]
75-
(reagent.ratom/reactive?))
72+
(some? (sr/get-current-observer)))

0 commit comments

Comments
 (0)