This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-15
Channels
- # admin-announcements (7)
- # alda (1)
- # aws-lambda (1)
- # beginners (12)
- # boot (20)
- # cider (59)
- # cljs-dev (4)
- # cljsrn (69)
- # clojure (232)
- # clojure-austin (3)
- # clojure-austria (1)
- # clojure-belgium (2)
- # clojure-canada (3)
- # clojure-dev (16)
- # clojure-greece (33)
- # clojure-nl (4)
- # clojure-quebec (12)
- # clojure-russia (12)
- # clojure-spec (27)
- # clojure-uk (38)
- # clojurescript (29)
- # community-development (7)
- # component (53)
- # core-async (16)
- # core-logic (1)
- # datascript (7)
- # datomic (11)
- # editors (7)
- # emacs (69)
- # hoplon (157)
- # keechma (1)
- # lambdaisland (2)
- # lein-figwheel (31)
- # leiningen (8)
- # mount (3)
- # off-topic (11)
- # om (23)
- # onyx (64)
- # planck (2)
- # re-frame (18)
- # reagent (21)
- # specter (118)
- # untangled (145)
- # yada (1)
What's the canonical way of deleting an entry in normalized data?
{:list/one [[:person/by-name "John"] [:person/by-name "Mary"] [:person/by-name "Bob"]],
:list/two [[:person/by-name "Mary"] [:person/by-name "Gwen"] [:person/by-name "Jeff"]],
:person/by-name
{"John" {:name "John", :points 0},
"Mary" {:name "Mary", :points 1, :age 27},
"Bob" {:name "Bob", :points 0},
"Gwen" {:name "Gwen", :points 0},
"Jeff" {:name "Jeff", :points 0}}}
This is taken from the Wiki example. In a mutate function operating on the data, how would I remove a person? An an example, just removing it from the :persons/by-name
key leaves it in the :list/one
/`:list/two` keys so the UI still renders it.It feels like the mutate function shouldn't have to remove it everywhere it's featured...that's the point of normalisation, right?
@acron: I think you just have to remove it from :persons/by-name
and every refs list that points to that table, just as you say. Seems sensible to create functions to do this for you. Here's the generic delete I use. It only removes from one referencing place, so needs improving for your case.
thanks @cjmurphy. As a relevant question, is normalisation mandatory? Seems like I'm spending a lot of time fighting it
Not mandatory. I think in terms of yes spend a lot of time with it, but activities are just different to other types of programming. It is like mutations are the only serious programming that needs to be done.
The other trick, of course, is persuading the UI element to re-render once removing the Person
For removing a person from many then that's not too tricky - the transact! has to be where this
is the parent component. Follow on reads a bit more difficult for me: I often use idents as follow on reads, just to specifically re-render a particular component. I ought to use keywords - in fact ought to replace all those uses with keywords.
@cjmurphy: That's an interesting nuance I wasn't aware of - transact!s need to always be on the parent UI?
Okay...so even using :value
in a mutate isn't enough to persuade a parent to re-render?
Yep - that's asked all the time here - 'just for documentation' is the answer for the purpose being :value
@anmonteiro: re: path navigation: Sorry for the late answer. I'm using a bidi+pushy approach and creating mutations depending on the url structure. That part is alright. It seems like path navigation is a separate concern than routing (if done right).
My biggest problem with routing has been sending the correct query to the remote(s). When I've gone with either subquery or set-query! solutions, the full-query has depended on props, and when gather-sends
is called after a transact!
with a route change mutation, the query hasn't been up-to-date. So I've had to transact!
route changes, then - possibly multiple - set-query!
, then a last transact!
to gather-sends
and using different hacks to prevent multiple requests.
I can now imagine a solution with unions that doesn't have problems with getting the remote query correct. I'll try to re-write our routing with unions and then probably transition to your lib. I'll let you know how it goes! Thanks ✌️