Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Dec 8, 2023
1 parent 591ab66 commit 8df95cc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/sci/configs/tonsky/datascript.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,25 @@
(let [methods (types/getMethods store)]
((get methods -store) store addr+data-seq)))

(def old-store storage/-store)

(def store-default
(defmethod -store :default [store addr+data-seq]
(storage/-store store addr+data-seq)))
(old-store store addr+data-seq)))

(set! storage/-store (fn [store addr] (-store store addr))) ;; DANGER, PATCH!

(defmethod -restore :sci.impl.protocols/reified [store addr]
(let [methods (types/getMethods store)]
((get methods -restore) store addr)))

(def old-restore storage/-restore)

(def restore-default
(defmethod -restore :default [store addr+data-seq]
(storage/-restore store addr+data-seq)))
(old-restore store addr+data-seq)))

(set! storage/-restore (fn [store addr] (-restore store addr))) ;; DANGER, PATCH!

(def IStorage-protocol
(sci/new-var
Expand All @@ -80,7 +88,8 @@
(def storage-namespace (assoc (sci/copy-ns datascript.storage storage-ns)
'-store (sci/copy-var -store storage-ns)
'-restore (sci/copy-var -restore storage-ns)
'IStorage IStorage-protocol))
'IStorage IStorage-protocol
))

(def namespaces {'datascript.core core-namespace
'datascript.db db-namespace
Expand Down

0 comments on commit 8df95cc

Please sign in to comment.