it has been quite some time since I touched re-frame so I'm in that purgatorial "I'm a beginner once more but not really" phase: if I have a layer 3 subscription that returns a "query vector" for another db item, is there a different means of extracting the data at that (returned) path besides reg-sub-raw. e.g. the following simplified example:
(rf/reg-sub
:view.normal/query
:<- [:view/id :normal]
:-> :view/data)
(rf/reg-sub-raw
:view.data/lines
(fn [app-db _]
(reaction
(let [query @(rf/subscribe [:view.normal/query])]
(get-in @app-db query)))))
the motivation is I'm trying to store data in a normalized formStoring data in normalized form doesn't really necessitate storing paths to some data in app-db.
In any case - yes, you should be using reg-sub-raw, in that exact manner.
But if nothing else uses :view.normal/query, then just use a plain reg-sub without any input signals and get both the path and the data at the path right in there. Even if :view.normal/query is used by something else, it's still something to consider - it will likely be around the same speed but won't have that impl that's... not ergonomic.
To be sure I understand your suggestion, you mean something like this instead:
(rf/reg-sub
:view.normal/query
(fn [db [_ q]]
(let [path (get-in db (into q [:view/data]))]
(get-in db path))))Not quite - the old version of :view.normal/query did not expect any arguments, so your new version is not the same.
I was walking about how :view.data/lines could be implemented differently.
(rf/reg-sub :view.data/lines
(fn [db _]
(let [q (get-view-normal-data-query db)]
(get-in db q))))
or, slightly better because it doesn't require extra data manipulation to construct the path
(rf/reg-sub :view.data/lines
(fn [db _]
(let [q (get-view-normal-query db)]
(-> db (get-in q) :view/data))))