⬆️ Upgrade to beicon2 (part1)

This commit is contained in:
Andrey Antukh 2023-12-21 20:02:49 +01:00 committed by Alonso Torres
parent ecee15af5b
commit 96f5a33f5f
151 changed files with 482 additions and 433 deletions

View file

@ -12,9 +12,9 @@
[app.common.schema :as sm]
[app.common.uuid :as uuid]
[app.main.data.workspace :as dw]
[beicon.core :as rx]
[beicon.v2.core :as rx]
[cljs.test :as t]
[potok.core :as ptk]))
[potok.v2.core :as ptk]))
;; ---- Helpers to manage global events
@ -26,48 +26,48 @@
(pp/pprint (sm/humanize-explain data))))
(defn prepare-store
"Create a store with the given initial state. Wait until
a :the/end event occurs, and then call the function with
the final state at this point."
[state done completed-cb]
(let [store (ptk/store {:state state :on-error on-error})
stream (ptk/input-stream store)
stream (->> stream
(rx/take-until (rx/filter #(= :the/end %) stream))
(rx/last)
(rx/do (fn []
(completed-cb @store)))
(rx/subs (fn [_] (done))
(fn [cause]
(js/console.log "[error]:" cause))
(fn [_]
(js/console.log "[complete]"))))]
store))
"Create a store with the given initial state. Wait until a :the/end
event occurs, and then call the function with the final state at
this point."
[state done completed-cb]
(let [store (ptk/store {:state state :on-error on-error})
stream (ptk/input-stream store)
stream (->> stream
(rx/take-until (rx/filter #(= :the/end %) stream))
(rx/last)
(rx/tap (fn []
(completed-cb @store)))
(rx/subs! (fn [_] (done))
(fn [cause]
(js/console.log "[error]:" cause))
(fn [_]
(js/console.log "[complete]"))))]
store))
;; Remove definitely when we ensure that the above method works
;; well in more advanced tests.
#_(defn do-update
"Execute an update event and returns the new state."
[event state]
(ptk/update event state))
"Execute an update event and returns the new state."
[event state]
(ptk/update event state))
#_(defn do-watch
"Execute a watch event and return an observable, that
"Execute a watch event and return an observable, that
emits once a list with all new events."
[event state]
(->> (ptk/watch event state nil)
(rx/reduce conj [])))
[event state]
(->> (ptk/watch event state nil)
(rx/reduce conj [])))
#_(defn do-watch-update
"Execute a watch event and return an observable, that
"Execute a watch event and return an observable, that
emits once the new state, after all new events applied
in sequence (considering they are all update events)."
[event state]
(->> (do-watch event state)
(rx/map (fn [new-events]
(reduce
(fn [new-state new-event]
(do-update new-event new-state))
state
new-events)))))
[event state]
(->> (do-watch event state)
(rx/map (fn [new-events]
(reduce
(fn [new-state new-event]
(do-update new-event new-state))
state
new-events)))))

View file

@ -10,7 +10,7 @@
[app.common.data :as d]
[app.common.geom.point :as gpt]
[app.main.data.workspace.libraries :as dwl]
[beicon.core :as rx]
[beicon.v2.core :as rx]
[cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true]
[clojure.stacktrace :as stk]
@ -18,7 +18,7 @@
[frontend-tests.helpers.libraries :as thl]
[frontend-tests.helpers.pages :as thp]
[linked.core :as lks]
[potok.core :as ptk]))
[potok.v2.core :as ptk]))
(t/use-fixtures :each
{:before thp/reset-idmap!})

View file

@ -17,7 +17,7 @@
[frontend-tests.helpers.events :as the]
[frontend-tests.helpers.libraries :as thl]
[frontend-tests.helpers.pages :as thp]
[potok.core :as ptk]))
[potok.v2.core :as ptk]))
(t/use-fixtures :each
{:before thp/reset-idmap!})

View file

@ -13,7 +13,7 @@
[frontend-tests.helpers.libraries :as thl]
[frontend-tests.helpers.pages :as thp]
[linked.core :as lks]
[potok.core :as ptk]))
[potok.v2.core :as ptk]))
(t/use-fixtures :each
{:before thp/reset-idmap!})

View file

@ -7,12 +7,12 @@
[app.test-helpers.events :as the]
[app.test-helpers.libraries :as thl]
[app.test-helpers.pages :as thp]
[beicon.core :as rx]
[beicon.v2.core :as rx]
[cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true]
[clojure.stacktrace :as stk]
[linked.core :as lks]
[potok.core :as ptk]))
[potok.v2.core :as ptk]))
(t/use-fixtures :each
{:before thp/reset-idmap!})