-
-
Save si14/db0ed40123c14a28b6f5808e3a824c1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def PACKAGE-ID s/Int) | |
(def PACKAGE | |
{:id PACKAGE-ID | |
:url s/Str | |
:inner_title s/Str}) | |
(def db-schema | |
{:package-ids [PACKAGE-ID] | |
:package/by-id {PACKAGE-ID PACKAGE}}) | |
;; probably not that efficient (if I understand correctly) | |
(register-sub | |
:packages | |
(fn [db _] | |
(reaction (mapv (:package/by-id @db) (:packages @db))))) | |
;; should be better (mapv will not be run on each @db change) | |
;; ...trivial :package/by-id and :package-ids subscriptions... | |
(register-sub | |
:packages-better | |
(fn [db _] | |
(let [package-by-id (subscribe [:package/by-id)]) | |
package-ids (subscribe [:package-ids])] | |
(reaction (mapv package-by-id package-ids)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment