Skip to content

Commit

Permalink
version 4-alpha-6: more sensible frontend updates
Browse files Browse the repository at this point in the history
  • Loading branch information
daslu committed Oct 25, 2021
1 parent af0d11b commit 60135cc
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).

## [4-alpha-6] - 2021-10-25
- more sensible frontend updates

## [4-alpha-5] - 2021-10-24
- event debounce
- bugfix in note editing on eval failure
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject scicloj/notespace "4-alpha-5"
(defproject scicloj/notespace "4-alpha-6"
:description "Notebook experience in your Clojure namespace."
:url "http://github.com/scicloj/notespace"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand Down
2 changes: 2 additions & 0 deletions src/scicloj/notespace/v4/change.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
note))

(defn edit-notes [state path edits]
;; (v4.log/log-data {:path path
;; :edits edits})
(update-in state
[:path->notes path]
editscript/patch (editscript/edits->script edits)))
8 changes: 4 additions & 4 deletions src/scicloj/notespace/v4/events/channels.clj
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@
async/<!
(group-by (comp event-priorities :event/type))
(sort-by (fn [[priority _]]
(-> priority nil? not assert)
priority))
;; ((fn [grouped-events]
;; (when (-> grouped-events seq)
;; (v4.state/add-formatted-message!
;; (v4.log/log-data
;; :debug1
;; {:grouped-events (->> grouped-events
;; (map (fn [[k events]]
Expand All @@ -76,7 +77,7 @@
events)))
;; ((fn [events]
;; (when (-> events seq)
;; (v4.state/add-formatted-message!
;; (v4.log/log-data
;; :debug2
;; {:events (->> events
;; (map #(dissoc % :value)))}))
Expand All @@ -86,8 +87,7 @@

(defn handle-events [in handler]
(async/go-loop []
(let [events (async/<! in)]
(run! handler events))
(handler (async/<! in))
(recur)))

(defn start! [handler]
Expand Down
14 changes: 8 additions & 6 deletions src/scicloj/notespace/v4/events/pipeline.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
[scicloj.notespace.v4.events.channels :as v4.channels]
[scicloj.notespace.v4.state :as v4.state]))

(defn handle-and-transact [event]
(defn handle-and-transact [events]
(try
(-> event
(assoc :state @v4.state/*state)
v4.handle/handle
v4.state/reset-state!)
(catch Exception e (println e))))
(doseq [event events]
(-> event
(assoc :state @v4.state/*state)
v4.handle/handle
(v4.state/reset-state! false)))
(catch Exception e (println e)))
(v4.state/reset-frontend!))

(defn start! []
(let [pipeline (v4.channels/start! #'handle-and-transact)]
Expand Down
1 change: 0 additions & 1 deletion src/scicloj/notespace/v4/frontend/change.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
(defn reset-frontend! [{:keys [current-notes]
:as details}]
(reset-frontend-header! details)
(v4.frontend.engine/reset-widgets!)
(->> current-notes
(mapcat (fn [note]
[[:view/source note]
Expand Down
5 changes: 3 additions & 2 deletions src/scicloj/notespace/v4/state.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@
v4.note/notes->counts)}))


(defn reset-state! [state]
(defn reset-state! [state frontend-too?]
(reset! *state state)
(reset-frontend!))
(when frontend-too?
(reset-frontend!)))

(defn pipeline []
(:pipeline @*state))
Expand Down

0 comments on commit 60135cc

Please sign in to comment.