-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support subscribing to subscriptions #2
Comments
Hello! re-dash subscriptions internally uses ClojureDart Cells to watch for changes to a specific key in app-db, which similar to re-frame would only result in recomputing the view if the value subscribed to actually changed. For example, given an app-db of {:name1 "Jack"
:name2 "Jill"} and the view subscribes to both names individually: (m/Column
.children
[(f/widget
:watch [name1 (rd/subscribe [::model/get-name1])]
(m/Text name1))
(f/widget
:watch [name2 (rd/subscribe [::model/get-name2])]
(m/Text name2))]) then say only Is there something more that multi layer subscriptions gives that I may be missing? |
Ahh the link you shared refered to layer 2 extractors, but I think you're referring to layer 3 materialised view mentioned here That requires some thinking, but yes, it would be nice to support |
Sorry, I meant to link to the layer 3 materialised view part... In re-frame these "input functions" |
Yes, according to the ClojureDart cheatsheat cells can have other cells as their dependencies. I'll experiment with it a bit in the next couple days |
Promising news, in the layer-3-materialised-view branch it works now where a subscription can subscribe to one other subscription (single signal) via the signals function Not yet implemented is to support a vector or a map of signals, but at the moment this works: ;; Layer 2 - Extractor
(rd/reg-sub
::get-count
(fn [db _query-vec]
(:current-count db 0)))
;; Layer 3 - Materialised View
(rd/reg-sub
::get-count-description
;; signals function
(fn [query-v]
(rd/subscribe [::get-count query-v]))
;; computation function
(fn [get-count _query-v]
(str "The count is exactly " get-count)))
|
Awesome! If you'd rather, I can help from there and implement the rest of the feature? |
I've just pushed a commit to this branch that adds support for a vector or map of signals |
re-frame supports multiple layers of subscriptions and it only recomputes what's necessary. cf https://day8.github.io/re-frame/subscriptions/#why-layer-2-extractors
How difficult do you think this could be to port to re-dash?
The text was updated successfully, but these errors were encountered: