Fork me on GitHub
#om
<
2015-11-12
>
noonian00:11:55

hmm, how to trigger renders when remotes return and the data is merged with the app state?

jannis00:11:34

@noonian: Add reads for the keys you want to re-read to the transact! call.

noonian00:11:16

@jannis: but what about normal reads that use remotes so no transact!?

noonian00:11:00

yeah it seems like I should put reads somewhere but I’m unclear on where they should go

jannis00:11:11

Component queries?

noonian00:11:15

the update happens when my send function calls the callback it is provided by om

noonian00:11:32

yeah, my root component wants the key :remote/msg and the read for that returns a remote ast which causes send to get data from the server which is correctly merged into the app state but no re-render

noonian00:11:41

do I need to manually transact! with a read after the remote data is merged in?

noonian00:11:49

on the reconciler

jannis00:11:13

What does the server return exactly?

jannis00:11:24

Is it a map like {:remote/msg ...}?

noonian00:11:38

although I could return something else if thats wrong

jannis00:11:45

No, that's correct.

noonian00:11:49

but that gets merged correctly

jannis00:11:05

query [:foo :bar] -> result {:foo ... :bar ...} is the format

jannis00:11:28

Does your read :remote/msg return a :value?

noonian00:11:33

right, everything seems to work except no re-render is caused

noonian00:11:28

I’ve tried with and without, if I supply one then my root component gets the initial value but not the new one when the state is merged from the remote. If I don’t supply one then it just never is rendered with that prop

jannis00:11:10

I think you have to return a :value that gets :remote/msg from the local state.

jannis00:11:50

And then it should work... if it doesn't: is the component and read code public?

noonian00:11:54

ahh, maybe my simplistic tests are foiling me

noonian00:11:45

heh, that fixed it

noonian00:11:08

I had been trying with just a hard coded value and it was always getting that. Stupid on my part.

jannis00:11:22

No problem

noonian00:11:02

this is the read code I’m using now which works great: https://www.refheap.com/111605

adamfrey04:11:27

If I am building an app with several distinct pages, does it make sense to use set-query! on the root component to swap the query out with a new page’s “root query” when the user switches pages?

dvcrn06:11:17

Alternatively I think you could put the reference to a component for that page somewhere and use get-query on that. Like current-component is DetailComponent which has subcomponents. Your root is just querying current-component. On a new page, you swap that with a different component

dvcrn09:11:37

Putting a presentation on om next together right now. One thing I noticed about relay is that you can defer elements that are not important, like if you want to have comments in your app but it's not critical, you defer it and it loads in whenever it is ready. Can I do something similar in next?

dvcrn09:11:07

It seems like the components will render when data is there. I'd like to give them a default value like :not-loaded-yet, which I could use to display loading indicators where necessary

dvcrn09:11:11

(defmethod read :foo/bar
  [{:keys [state] :as env} key params]
  (if (find @state key)
    {:value (get-data state key)}
    {:remote true :value :not-loaded-yet}))
sadly doesn't work 😛

jannis10:11:04

@dvcrn Looks ok to me except I'd deref the state once only. It might change between find and get-data. (I really don't know anything about concurrency in JS...) What doesn't work exactly?

bplatz12:11:05

@dvcrn: Partial loading is something I've been interested in as well. So far no delay-like capability. Your primary option is to filter your queries based on your current state, or use query params to change their behavior. Both involve embedding extra logic in your reads to figure out if it should be elided.

dvcrn12:11:52

Maybe @dnolen has some thoughts on this

dnolen14:11:25

@dvcrn just return :value :not-loaded-yet

dnolen14:11:05

only return :remote true when you need the data.

boz16:11:39

I get ReactDOM is not defined if I use Sablono and take out om.dom in the om.next quick-start. Is that expected? I’m using om 1.0.0-alpha19 Here’s the “broken” version...

(ns om-tutorial.core
  (:require 
            [goog.dom :as gdom]
            [om.next :as om :refer-macros [defui]]
            ;;[om.dom :as dom]
            [sablono.core   :as html  :refer-macros [html]]))

(defui Counter
  Object
  (render [this]
          (html [:div "Howdy"])))

(def counter (om/factory Counter))

(js/ReactDOM.render
 (counter)
 (gdom/getElement "app”))

dnolen16:11:30

@boz you need to verify that your environment is OK

dnolen16:11:50

lein deps :tree and make sure your deps are correct

dnolen16:11:06

make sure you are building clean to eliminate variables while fixing the issue

dnolen16:11:15

as far as I know nobody else has this problem you are describing

dnolen16:11:44

@boz oh oops, reading more closely - yes that changed

dnolen16:11:59

om.next doesn’t rely on om.dom anymore for React Native.

dnolen16:11:10

so that behavior is expected

noonian16:11:19

You can workaround it by by requiring cljsjs.react.dom in one of your own namespaces.

boz16:11:54

Thanks @dnolen and @noonian . Requiring cljsjs.react.dom fixed it too. simple_smile

boz16:11:43

@dnolen: … I’m using boot in place of lein, just for the heck of it. Not surprisingly, it works too. All good stuff.

joshfrench17:11:44

@jannis can i ask how you wired up the server-side bits of tempids? i tried passing om.next.server/reader to my middleware and then saw you’d already attempted that with no luck.

jannis17:11:49

After that, you have to return a :tempids map from mutations that create real IDs. I'm simply reusing the id part of tempids for the real IDs at the moment: https://github.com/Jannis/copaste/blob/master/src/server/parsing/copaste.clj#L78

joshfrench17:11:39

i’ll take a look, thanks!

jannis17:11:12

@joshfrench: Any questions, just ask simple_smile

dnolen18:11:56

I will fill out these first two questions shortly

dnolen18:11:18

the idea is commonly asked questions that have 5-10 line answers

dnolen18:11:32

feel free to add things as long as it fits these constraints

thosmos18:11:26

@boz: In my build.boot I have react and react-dom "0.14.0-1" in my deps and then: [sablono "0.4.0" :exclusions [cljsjs/react] [org.omcljs/om "1.0.0-alpha20" :exclusions [cljsjs/react cljsjs/react-dom]]

noonian18:11:41

hmm, is tree->db intended remove values that are not included in the given components query?

boz19:11:30

@thosmos: like this?

(set-env!
 :source-paths #{"src"}
 :resource-paths #{"resources"}
 :dependencies '[[org.clojure/clojure   "1.7.0"]
                 [org.clojure/clojurescript "1.7.170"]
                 [adzerk/boot-cljs      "1.7.48-6"   :scope "test"]
                 [adzerk/boot-cljs-repl "0.2.0"]
                 [adzerk/boot-reload    "0.4.1"]
                 [pandeiro/boot-http    "0.6.3"      :scope "test"]
                 [cljsjs/react "0.14.0-0"]
                 [cljsjs/react-dom "0.14.0-0"]
                 [org.omcljs/om "1.0.0-alpha20" :exclusions [cljsjs/react cljsjs/react-dom]]
                 [sablono "0.4.0" :exclusions [cljsjs/react]]])

boz19:11:15

I don’t think sablono has a cljsjs/react dependency. At least it’s not listed on http://clojars.org or in my deps graph (before making the above change.

boz19:11:28

I still get the same behavior. e.g., have to require cljsjs.react.dom in my cljs namespace.

thosmos19:11:40

Oops, I just took a closer look at your example, you're calling js/ReactDOM directly, so yes you'd need to require cljsjs.react.dom

boz19:11:37

It happens with om.next’s add-root! too, which defaults to using ReactDOM … it’s documented. I just didn’t get it.

boz19:11:52

I’m curious. What else could be used in place of ReactDOM.render for add-root! ?

dnolen19:11:13

@noonian: yes, we could change that but would like to hear more rationale about why you have stuff not in queries

dnolen19:11:30

@noonian: in any serious application with a remote component that wouldn’t even be possible

jannis19:11:51

@boz: I think for Om to work with React Native, you have to use something else instead of ReactDOM.render.

thosmos19:11:39

@boz ReactDOMServer.renderToString

jannis19:11:21

Oh yes, that as well.

thosmos19:11:17

I'm attempting to use a normalized datascript db where entity refs use the :db/id , like so: {:db/id -6 :type :dashboard/list :list/title "A List of Various Media" :list/items [-1 -2 -3 -4 -5]}

thosmos19:11:39

is it possible to make this work with om/Ident without creating a separate items-by-id index?

noonian19:11:08

@dnolen: I’m curious why it woudn’t work for remote. But my issue fundamentally has to do with normalization. I have a parser with recursive reads (which are reflected in the query as keys that do not show up in the data I want to normalize). That means that tree->db with the root component doesn’t really work to normalize the data. It does work to normalize with the sub query fragment that is inside the recursive key. So I’m manually normalizing my data using that approach currently but if the outer component wants any keys tree->db will strip them from the data unless I “whitelist” the keys by adding them to the sub query which is dirty. It seems to me that you will run into this issue anytime you have components that leverage recursive parsers. It also seems like any sort of routing example requires a recursive parser.

thosmos19:11:04

If I try to set the Ident to just a plain id I get an error: (defui Post static om/Ident (ident [this {:keys [id]}] id) ... error: Uncaught TypeError: Cannot read property 'om$isComponent' of null

dnolen19:11:46

@noonian: a remote should never send keys a client didn’t request anyway

dnolen19:11:50

you could never be in this situation

noonian19:11:07

@dnolen: ah yeah, this is all client side

dnolen19:11:52

@noonian: I see your point though

dnolen19:11:08

you could for example have some data with a bunch keys

dnolen19:11:20

and some query isn’t part of normalization that will needs those keys later

noonian20:11:02

Does this approach of manually normalizing the data when using a recursive parser make sense? It also leads to questions about how to merge in new data from remotes. Currently I think I’d have to keep Om not auto-normalizing and override merge functions to do my custom normalization because Om hardcodes calls to tree->db on the root component. But if one could instead configure the reconciler with a function to get the query to normalize with it would allow someone with a recursive parser to take advantage of auto-normalization without implementing custom merge functions etc.

dnolen20:11:30

@noonian: well you need to be able to turn this stuff off

dnolen20:11:42

so that’s well supported

dnolen20:11:59

however I don’t really understand why you want to do that since it automates a lot of work for you

thosmos20:11:13

This works. I was mixing up how datascript handles references in queries with how Om knows an entity's id. (defui Post static om/Ident (ident [this {:keys [id]}] [:db/id id])

noonian20:11:10

@dnolen: I think I need to post some queries to make this explicit and also my goals as far as the structure of app-state.

dnolen20:11:39

@noonian: yeah I don’t know how you would have ended up here

dnolen20:11:49

it really doesn’t make sense to me at the moment

dnolen20:11:53

@noonian: tree->db no longer drops data, fixed in master

noonian20:11:21

@dnolen: ok here is a minimal example of what I’m talking about that builds on the “Components, Identity & Normalization” tutorial: https://www.refheap.com/111633 Left out is the motivation for the recursive read but its basically the same reason as in https://github.com/jdubie/om-next-router-example/blob/master/src/om_router/core.cljs

dnolen20:11:22

@noonian: that’s just a lot of code with no explanation of what I should be looking at

mitchelkuijpers20:11:27

I am currently trying the Quickstart and I get the following error with the part where I start fighweel for the first time:

Analyzing src/om_tutorial/core.cljs
Analyzing jar:file:/Users/mitkuijp/.m2/repository/org/omcljs/om/1.0.0-alpha20/om-1.0.0-alpha20.jar!/om/dom.cljs
Exception in thread "main" clojure.lang.ExceptionInfo: No such namespace: cljsjs.react, could not locate cljsjs/react.cljs, cljsjs/react.cljc, or Closure namespace "cljsjs.react" {:tag :cljs/analysis-error}, compiling:(/Users/mitkuijp/Development/om-tutorial/script/figwheel.clj:17:1)
Anyone recognize this?

noonian20:11:10

@dnolen: hehe ok sorry. The People component is the RootView component from the tutorial. All I do is nest that under the :page/content key which in the read implementation just parses the query from the root.

noonian20:11:27

so now that whole tutorial is nested under a root component

noonian20:11:56

in the comments below you see the result of om/get-query and om/tree->db

noonian20:11:04

I cant use the root to normalize in this scenario

noonian20:11:29

and the automation you were talking about hardcodes that tree->db is called with the root component

noonian20:11:02

so in short I’d love to use that automation but either I need to find a different approach or configure what query om will use for normalization

noonian20:11:29

because the structure of init-data does not match the shape of the root query (due to the recursive parse key)

dnolen20:11:46

this still isn’t making any sense to me at all (I’m willing to figure it out though)

dnolen20:11:57

is the problem here that you don’t want to choose a page to start on?

noonian20:11:44

that is sort of why you would want to nest something that queries keys at the root under a parent component

noonian20:11:06

but its more the mismatch between the shape of the app state and the shape of the query

noonian20:11:31

which I believe will happen anytime you have a UI tree that uses keys that trigger recursive parses

noonian20:11:13

because even if I choose which one I want, I can

noonian20:11:48

can’t normalize with the root

dnolen20:11:59

@noonian you’ve said a couple of things that make no sense to me

noonian20:11:12

I’m sorry please ask me questions so I can clarify

dnolen20:11:12

1) mismatch between app state and shape of query

dnolen20:11:22

no such thing

dnolen20:11:32

if you are doing this you don’t want to use Om period

dnolen20:11:53

2) believing this occurs because of recursive parse

dnolen20:11:58

absolutely not

dnolen20:11:14

tons of people are writing recursive parse without your problem

noonian20:11:38

ok, this is the query in question that I would like to be able to normalize data with: [{:page/content [{:list/one [:name :points]} {:list/two [:name :points]}]}]

dnolen20:11:35

what is stopping you from doing that

noonian20:11:37

are you saying that I can’t maintain app state of the shape:

{: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 0},
    "Bob" {:name "Bob", :points 0},
    "Gwen" {:name "Gwen", :points 0},
    "Jeff" {:name "Jeff", :points 0}},
   :om.next/tables #{:person/by-name}}
with that query?

noonian20:11:54

that all works fine, the problem is if I want to use tree->db

noonian20:11:18

or use auto-normalization which calls tree->db

dnolen20:11:22

right this won’t work

dnolen20:11:28

let’s rewind and reset here

dnolen20:11:42

what does tree->db do fundamentally ...

dnolen20:11:03

it takes a thing which matches the query and transforms it into a database

dnolen20:11:16

there’s no such thing as giving it a thing which doesn’t match the query

dnolen20:11:36

but nothing is stopping you from writing a normalized initial app state

dnolen20:11:52

and leveraging normalization later

noonian20:11:53

right, I understand that, but the query I want to use for normalization isn’t the root query. I think you are saying that isn’t something you want to do with Om but I am trying to understand why not now.

dnolen20:11:26

why not, because I just don’t care about this problem

dnolen20:11:37

either supply the normalized thing yourself and be done with it

dnolen20:11:43

or supply the correct initial data

noonian20:11:57

ok, in this case what would that look like?

dnolen21:11:30

you need a union

dnolen21:11:35

but your example doesn’t use one

noonian21:11:49

so wouldn’t it be something like this?:

(def init-data
  {:page/content
   {:list/one [{:name "John" :points 0}
               {:name "Mary" :points 0}
               {:name "Bob"  :points 0}]
    :list/two [{:name "Mary" :points 0 :age 27}
               {:name "Gwen" :points 0}
               {:name "Jeff" :points 0}]}})

dnolen21:11:06

ok I think I finally see where the issue might be

dnolen21:11:15

normalization on unions works correctly for collections

noonian21:11:18

that makes sense to me, but throws an error in tree->db I believe because one of the components in the tree doesn’t have an ident

dnolen21:11:18

but not singletons

dnolen21:11:35

@noonian: yeah I’m pretty sure this is the problem

noonian21:11:49

by singletons you mean components without idents?

dnolen21:11:15

no I mean you have some singleton value that can be many kinds of things

dnolen21:11:26

:value (X|Z)

dnolen21:11:29

but we only spuport

dnolen21:11:36

:value [(X|Z)*]

noonian21:11:24

ok, but even then I would expect to be able to normalize this data with the root query above:

noonian21:11:31

{:page/content
   [{:list/one [{:name "John" :points 0}
                 {:name "Mary" :points 0}
                 {:name "Bob"  :points 0}]
      :list/two [{:name "Mary" :points 0 :age 27}
                 {:name "Gwen" :points 0}
                 {:name "Jeff" :points 0}]}]}

noonian21:11:00

is that a correct expectation? if so I think theres a bug in Om, if not then Im misunderstanding something.

noonian21:11:17

and the query: [{:page/content [{:list/one [:name :points]} {:list/two [:name :points]}]}]

mitchelkuijpers21:11:35

Hmm I got the quickstart working with the following project.clj

(defproject om-tutorial "0.1.0-SNAPSHOT"
  :description "My first Om program!"
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.145"]
                 [org.omcljs/om "1.0.0-alpha20"]
                 [com.cognitect/transit-clj "0.8.281" :scope "provided"]
                 [com.cognitect/transit-cljs "0.8.225" :scope "provided"]
                 [figwheel-sidecar "0.5.0-SNAPSHOT" :scope "provided"]])

dnolen21:11:47

@noonian: that query is perfectly valid already for that data shape

dnolen21:11:51

this is what everyone is already doing

dnolen21:11:21

@noonian: ah no it isn't

dnolen21:11:29

and no that’s not going to work

dnolen21:11:43

query and structure of your data always has to match - this is never going to change

dnolen21:11:00

this is in fact the whole point

noonian21:11:01

so does that not match?

noonian21:11:04

Yeah, I guess I really don’t understand the algorithm behind tree->db

dnolen21:11:22

it does match but it’s impossible to see this so much context

noonian21:11:38

I think I can strip this down a bit

noonian21:11:06

and get it closer to the original tutorial

dnolen21:11:22

[{:x [{:y …} {:z …}]}] matches {:x {:y … :z …}} AND {:x [{:y … :z …}]}

dnolen21:11:11

@noonian: and actually that issue doesn’t make sense we can’t normalize singletons since we don’t know which one to pick

dnolen21:11:31

@noonian: but I think now understand the conceptual difficult you are having

noonian21:11:37

i’m having trouble even if its a collection

dnolen21:11:43

other people are having this problem as well

dnolen21:11:39

and the answer is always the same - fix this in the data

dnolen21:11:54

your initial data should look something like this

dnolen21:11:33

{:pages [….] :current-page [:pages :main]}

dnolen21:11:56

and normalization should not break this, it’s a bug if it does

dnolen21:11:04

your query should be

dnolen21:11:47

[{:pages […]} {:current-page […]}]

dnolen21:11:55

where those subqueries are the same

noonian21:11:37

and all data for each page should go in pages and use references to point to tables of denormalized data if it represents the same data right?

dnolen21:11:54

@noonian: sorry for taking so long to understand what you were asking about simple_smile

noonian21:11:56

so pages is a vector of maps?

noonian21:11:20

ok, lemme see if I can get data looking like that to normalize

noonian21:11:23

then I’ll be happy

dnolen21:11:38

yeah I’m double checking things over here to make sure there isn’t a bug for this case

dnolen21:11:41

pretty sure there is

dnolen21:11:49

since I don’t have any tests around “partially” normalized data

dnolen21:11:27

@noonian: fixed in master

noonian21:11:47

@dnolen: thanks I’ll check it out. So there was a bug then?

dnolen21:11:56

@noonian: btw thanks for pushing along the local-centric point of view

dnolen21:11:04

been a bit focused on the remote stuff so easy for me to miss cases like this

dnolen21:11:14

@noonian: definitely a bug

noonian21:11:25

np, its what I’ve been trying to get working since I jumped into Om next but was suprised no one else seemed to run into this

dnolen21:11:27

you should always be able to have your own links in the data

dnolen21:11:43

and normalization should not touch it

dnolen21:11:31

this pretty much the exact same kind of issue

dnolen21:11:45

but the point remains, think about links

dnolen21:11:57

try to fix things in the data not in Om Next machinery

noonian21:11:12

yeah, I was definitely pushed that way but I think I hit bugs that I thought were om next semantics hehe

kschrader21:11:41

@dnolen: I had the same problems as @mitchelkuijpers trying to run through the Quick Start last night and I can confirm that adding the transit deps and using figwheel-sidecar “0.5.0-SNAPSHOT” fixes the issue

dnolen21:11:25

@kschrader: ah right … will fix

mitchelkuijpers21:11:38

Awesome quickstart btw @dnolen Finally time to play with om.next

kschrader22:11:03

agreed, really helps getting started

noonian22:11:30

@dnolen: ok I’m still having trouble normalizing with a union. I have a much smaller example now but the tables created by tree->db have nils instead of the ids from props. Either a bug still or my data/query syntax is off. Here’s the example: https://www.refheap.com/111640

noonian22:11:08

ident is called twice for the page during normalization and with print debugging it seems it only gets the correct props the first time called

dnolen22:11:31

@noonian your query doesn’t make sense given the data

dnolen22:11:58

the query for PageView

dnolen22:11:34

@noonian: oh that’s your union query

noonian22:11:52

yeah, I based it off the union tutorial and tried to make sure the shape of everything was the same

noonian22:11:45

so PageView corresponds to DashboardItem and RootView to Dashboard and PeoplePage to Post, Photo, or Graphic

dnolen22:11:54

@noonian: oh simple bug

dnolen22:11:02

PeoplePage is missing :id

noonian22:11:28

in the query?

noonian22:11:33

doesn’t seem to affect anything

dnolen22:11:42

you need it

dnolen22:11:57

otherwise you can’t compute ident whenever you want

noonian22:11:00

I think the issue is in the union. In the tutorial you are unioning on the type of the dashboard item. How does Om know to compute the union from the type key?

dnolen22:11:18

there’s nothing wrong with the union

dnolen22:11:20

everything looks fine to me

dnolen22:11:28

but PeoplePage missing :id is a bug

noonian22:11:30

add :id to the query doesn’t change the behavior

dnolen22:11:59

ok looking but that is a bug

noonian22:11:01

are the keys in the union used at all?

dnolen22:11:32

no they aren’t again a thing for remotes

dnolen22:11:38

but we need the queries

noonian22:11:47

and a way to differentiate them

dnolen22:11:39

@noonian: your code example works here

dnolen22:11:56

@noonian: make sure you clean your build

dnolen22:11:08

you need :id

dnolen22:11:33

alpha21 released with deps fixes so tutorials work again

dnolen22:11:39

@jannis you might want to test migrate

dnolen22:11:07

@jannis also I don’t know about OM-470 anymore https://github.com/omcljs/om/issues/470

noonian22:11:15

@dnolen: hmm, you got tree->db to work with that code?

dnolen22:11:18

I don’t see why you can’t just use om/get-query

dnolen22:11:24

@noonian: yep worked perfectly

noonian22:11:46

weird, something must be up with my environment then

noonian22:11:55

om/get-query works fine

dnolen22:11:18

@jannis I don’t know why om/get-query isn’t good enough for OM-470

jannis22:11:58

@dnolen: How do you suggest to use it there?

dnolen22:11:28

the problem is for the case where some other component listens on that key

noonian22:11:51

@dnolen: ah I got it working. I must have git pulled too soon and still had the buggy version. Re-pulling and installing alpha22-SNAPSHOT fixed it simple_smile

noonian22:11:58

thanks for your help and patience

jannis22:11:05

1) if the component listens to it, you want to pass in the query the component uses for that key, not just the key itself, otherwise query in read will be empty on the remote end and you'll get nothing useful back

dnolen22:11:13

@jannis so how about this … thinking out loud ...

dnolen22:11:37

if a user drops a key, find all the components that listen on that key and get their queries for that key

dnolen22:11:39

merging them

jannis22:11:56

2) if other components listen for the same key... I don't know... would we collect and re-execute all queries for keys passed to transact! and send them all over?

jannis22:11:03

Ok, listening to you now

dnolen22:11:23

so for example :user/playlist

dnolen22:11:29

maybe 3 components listen to this

dnolen22:11:37

each need different things

dnolen22:11:13

actually we should probably just do the simplest thing that works

dnolen22:11:23

so find each component that listens on the key (the indexer knows)

dnolen22:11:31

and get their query for that key

jannis22:11:49

Yep, sounds good

jannis22:11:25

It's kinda what my hack does except doing it the right way (via the indexer) and for other components as well

jannis22:11:49

I totally forgot about other components

jannis22:11:04

@dnolen: Migrate still works. What's id-key for? (Apologies, I'm really tired simple_smile )

jannis22:11:27

Oh, it allows to set :id or whatever represents the ID from the real ID in the tempid mapping?

dnolen22:11:18

@jannis yes it just for the case where you just don’t want to read anything

dnolen22:11:26

you just want the new id

dnolen22:11:30

but need to know what the standard id key is

jannis22:11:35

Yeah, so you can inject it into the entity/object in the client tree. I get it. Cool simple_smile

jannis22:11:09

Assuming the server doesn't do anything but create a real ID and store the rest as-is, that makes no-effort transactions possible; the client doesn't have to do anything else at all unless they fail on the server side

jannis22:11:45

Did I mention migrate still works?

jannis22:11:54

Oh, I did simple_smile

dnolen22:11:55

yes, cool thanks for the report

jannis23:11:31

(Mmh, parinfer is cool. Comment the last line of a function with a lot of ))))))))) out and it just moves the parens up to the last line still in use.)

dnolen23:11:40

added examples on delayed loads and optimistic commits https://github.com/omcljs/om/wiki/Om-Next-FAQ

jannis23:11:41

If I see something like this TaggedValue in the transaction response data, the client hasn't properly handled the transit response, right? This fragment passed to the send callback and :id-key doesn't work: :tempids {[:snippet/by-uuid #object[Object [TaggedValue: om/id, ab6596ec-e154-429b-9fba-7f6a03ed619a]]] [:snippet/by-uuid ab6596ec-e154-429b-9fba-7f6a03ed619a]}

dnolen23:11:35

@jannis yeah that means writing didn’t work for some reason

jannis23:11:22

Writing (server) or reading (client)?

dnolen23:11:36

could be either

dnolen23:11:53

you would need to check

jannis23:11:08

Will do. Certainly not Om's fault anyway simple_smile

jannis23:11:33

@dnolen: Actually... shouldn't the CLJS version of om.transit/reader also use ReadHandler?

dnolen23:11:29

no read handlers are just functions

dnolen23:11:33

only write handlers are types

dnolen23:11:44

in transit-cljs

dnolen23:11:24

I can verify that CLJS transit bits round trip

dnolen23:11:43

i.e I can write/read a tempid

dnolen23:11:25

so I’m pretty excited about the Om Next caching story

dnolen23:11:46

requires none of the craziness that Relay & Falcor are pursuing due to lack of HTTP Caching narrative

dnolen23:11:19

turns out ident migration is a great time to prune the application state of unreachable information

dnolen23:11:28

so there’s nothing more for us to do

dnolen23:11:55

and I don’t need to bother with crazy logic, we can just lean on browser caching

dnolen23:11:58

as it should be!

jannis23:11:50

How does migrate know which idents to get rid of?

dnolen23:11:29

@jannis it doesn’t need to

noonian23:11:32

is ident migration moving data to ident tables in db->tree? if not when does that happen?

dnolen23:11:46

we just drop all the generated tables

dnolen23:11:55

and rebuild

dnolen23:11:02

we have to anyway for ident migrations

dnolen23:11:19

because all those links in the data could be bad

jannis23:11:27

Ah, of course. And migrate happens for everything returned by the server, so when e.g. {:list/one ... :list/two ...} are returned, it rebuilds and all people that aren't returned anymore disappear.

dnolen23:11:20

@noonian: we only look at the tables in the sense that we need to build the full tree

dnolen23:11:30

as we do that we replace any old links

dnolen23:11:44

then we invoke tree->db to get a fixed up thing

dnolen23:11:56

any refs that weren’t in the tree of course will get discarded

noonian23:11:39

I see, and what initiates that process? the send function calling the merge callback? So build the data tree by following refs, then merge in new unnormalized data, then renormalize?

dnolen23:11:39

basically GC

dnolen23:11:02

@noonian: this only is applied for the remote case where :tempids are returned for mutations

dnolen23:11:17

but nothing’s stopping you from doing this yourself if you’re doing local only

noonian23:11:18

I haven’t done any remote mutations yet just have remote reads going

noonian23:11:29

not local only, but was working on the local story first

noonian23:11:38

routing, specifically