This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-10
Channels
- # admin-announcements (2)
- # arachne (2)
- # beginners (53)
- # boot (52)
- # cider (7)
- # cljs-dev (61)
- # cljsrn (12)
- # clojure (61)
- # clojure-greece (22)
- # clojure-nl (16)
- # clojure-russia (103)
- # clojure-spec (84)
- # clojure-uk (15)
- # clojurescript (137)
- # community-development (14)
- # cursive (4)
- # datomic (14)
- # devcards (6)
- # euroclojure (3)
- # funcool (26)
- # hoplon (27)
- # jobs (4)
- # lambdaisland (1)
- # leiningen (1)
- # om (75)
- # onyx (77)
- # planck (15)
- # proton (2)
- # re-frame (23)
- # ring-swagger (9)
- # schema (1)
- # specter (95)
- # untangled (124)
- # yada (27)
@kenbier: feel free to make that than an issue and assign it to me
the todomvc has optimistic updates, but let's say I just want to merge in my updates after server processes the remote mutation
@jasonjckn: Remote mutations have no query, so it does not make sense to return a value (because we would not know how to properly merge the result in the graph db)
Trying to remember where I wrote about that...I know I wrote something about that somewhere
Basically, add an (app/load ...)
to your transaction after your mutation. This allows you to specify the query (and optionally the post-mutation symbol) used to integrate the response with your app state.
oh wait. I think we fixed the naming of that from app/load
...yeah, it is now called untangled/load
as of recent versions..
@kenbier: in case the avatar pic isnt enough, I’m Pancia
on github
@tony.kay: finally got to upgrading to 0.5.0 in our app - noticeably better performance when our data comes back and gets merged in.
OK, fun additions coming to Untangled today! We've worked out a nice way of adding initial state constructors to the UI tree (so you don't have to build initial state in a central single place). Nice and composable, AND it also enables a really cool merge function that is super useful for initializing Union data and merging in incoming components (e.g. from server push).
That sounds pretty useful - especially since we're going to need to figure out server push merging at some point in the not-to-distant future
It also helps eliminate the need to ever hand-build initial state (even in the union case, which is a struggle if you're wanting to use unions for your tabs)
Sample of constructors: https://github.com/untangled-web/untangled-cookbook/blob/develop/recipes/recipe-template/src/client/app/ui.cljs
Tabbed interface recipe updated. Shows how to initialize any number of tabs without having to make initial app state as a monolith
@tony.kay: sweet
is there a upgrade path documentation from 0.4 to 0.5, i just bumped the dependency and now the app won't start
am reading this https://github.com/untangled-web/untangled-client/blob/develop/CHANGELOG.md
@jasonjckn: what error are you getting?
I just upgraded a 10000+ line app and it worked fine, it was just the server refresh that needed some love
if you remove initial state and use constructors it'll be fine...I'll fix it, though, of course
actually, you can sort of use both. If you don't make a root constructor, then you can compose things together by hand and pass them as initial state.
i don't think it would be a problem to move everything to constructors, but i also don't see any design issues with merging constructor state into initial state
you're better off either doing the app state by hand so it is right, or using just constructors
but I think you can do it all with constructors unless I've missed something, and it is much cleaner
not all of my links correspond to defui components, for example i load-data into {:search-results {:global {:items ... :total-count ... }}
so if I want to initialize :search-results :global with some data, i'm writing hand normalized data into the Root constructor I guess
so, instead of putting it in the root constrcutor (in which case you'd have to include the query), you can instead use merge-state!
in the started-callback
so that was my use case for passing a hand normalized atom to create client, and also using constructors
my use case is the data is already normalized and there's no om/Ident that would normalize it
so I write defui's for non-ui concerns, then I include them in the Root query (?), even though I don't need this info in the Root props, ?
what about for links like [:search-results '_] that have hand normalized data like {:search-results {:items .. :total-count ..} this is all supported too?
(merge-state! app SearchResultComponent search-result-tree :replace [:search-results])
you could also skip links, and give SearchResultComponent an ident like [:search-results :main], then instead of querying on a link, you'd join on that ident.
the add-on parameter (replace, append-to, and prepend-to) are for joining the ident into another spot in app state
@jasonjckn: Here is a sample to play with..
I just added some comments to help with comprehension...so pull if you already cloned
@tony.kay: i'm testing with 0.5.2 using an atom of initial state, and definitely past that initial exception thank you, however there's some remote data loaded that use to be deeply merged into atom, and now it's replacing that data, here's my initial state:
(def initial-state
{
:search-results {:global {:items [] :page-size 1 :offset 0}}
:search {:tab {:which-tab :search :content "Main"}}
:settings {:tab {:which-tab :settings :content "Settings"}}
:current-tab [:search :tab]
})
as you can see page-size 1, after an untangled/load, the page-size key dissapears(defmethod api-read :search-results
[{:keys [elasticsearch ref]} key {:keys [query offset] :or {offset 0}}]
{:pre [(some? query)]}
{:value
{:global {:query query
:offset offset
:items (->> (esd/search elasticsearch
"entities" "message"
:query {:query_string {:query query}}
:from offset
:size 1)
:hits
:hits
(map :_source)
(into []))}}})
if so, Untangled will remove it if the server does not send it...because you asked for it, and it looks like it has disappeared
your options: don't ask for it (Untangled will leave it), ask for it and reply with it