(ns fiddles.targeting
(:require
[com.fulcrologic.fulcro.algorithms.data-targeting :as targeting]))
(comment
;; this one works
(targeting/process-target
{:a {:b {:c 1}}}
[:a :b :c]
[:new-loc/id 999]
true) ; {:a {:b {}}, :new-loc/id {999 1}}
;; works again
(targeting/process-target
{:a {:b {["x" "y"] 1}}}
[:a :b ["x" "y"]]
[:new-loc/id 999]
true) ; {:a {:b {}}, :new-loc/id {999 1}}
(targeting/process-target
{:composite-key {["x" "y"] 1}}
[:composite-key ["x" "y"]]
[:new-loc/id 999]
true)
; {:composite-key {["x" "y"] 1},
; :new-loc/id {999 [:composite-key ["x" "y"]]}}
bug?Thanks. Makes sense. Looks like source-path interprets any two-element vector/path as an ident and doesn't check if it's a keyword, and in such cases the remove-source? argument isn't used at all. Do you think it would be helpful to clarify this in the docstring? I can patch it if you think so.
This function is really meant for internal use by the targeting system. I’ve never called them directly in any application I’ve built in the years since I created it. You can send a patch for the docstring if you want
Fair enough 🙂 thanks for clarifying.
Not a bug. Source path can be an ident. And you’ve given it something that looks like an ident. The docstring clearly says: `
If the source path is an ident, then that is what is placed
in app state.
an ident is defined as a vector with a keyword as the first element. The ID is allowed to be anything
this is to preserve normalization
the fact that your target path was an ident is just not a supported case that the design intends