Fork me on GitHub
#om
<
2015-11-26
>
dnolen00:11:13

a very short but very important post

wilkerlucio00:11:27

@dnolen: wondering, this is valid using idents? [{[:current_user _] [:person/name]}]

dnolen00:11:04

@wilkerlucio: yep refer to the grammar

wilkerlucio00:11:45

cool, going play with it simple_smile

tony.kay00:11:04

@dnolen: That does make things nice. I had not been realizing db->tree could be used that way...obvious now!

tony.kay00:11:54

time to rewrite a bunch of stuff simple_smile

dnolen00:11:43

@tony.kay: yeah this is a radical simplification

dnolen00:11:52

clientside parsing should really only be about top level keys

tony.kay00:11:02

I like your comment "pretty boring stuff" at the first sight of db->tree in read.

dnolen00:11:26

in fact itā€™s making me realize we may want to move some this stuff into a .cljc file

tony.kay00:11:34

"oh, and here is this little tidbit that will change everything...pretty boring, I know"

dnolen00:11:35

since it solves a lot of problems for server side code as well

jannis00:11:00

@dnolen: Excellent feature!

dnolen00:11:00

wrapping up will look for feedback

dnolen00:11:08

happy Thanksgiving people!

wilkerlucio01:11:27

happy thanks giving simple_smile

colinf08:11:09

@thomasdeutsch: seems ok for me. The only thing I can suggest is to check your clojurescript version in project.clj

juhoteperi09:11:31

The new documentation page is just what I was missing!

thomasdeutsch10:11:44

@dnolen: [:id :name [:current-user _]] is nice. - what if i only want parts of the current-user? like: [:current-user [:id :name :email]]

jannis11:11:34

@thomasdeutsch: I'm guessing it returns whatever the root asks for, so if the root only has [... {:current-user [:id :name]}], you'd get :id and :email.

jannis11:11:43

But that's just a guess.

thomasdeutsch11:11:26

@jannis: i am talking about the new option to link to a root key - accessing parts of the object is not possible at the moment - as far as i can tell.

jannis11:11:05

@thomasdeutsch: Oh, actually.... have you tried this? [:id :name {[:current-user _] [:id :name :email]}]?

jannis11:11:17

@wilkerlucio was asking whether that was valid earlier and @dnolen said yes.

thomasdeutsch11:11:10

@jannis: yes, you are right - this is it.

jannis11:11:01

(And I was wrong thinking it had anything to do with the root query... it's simply reaching into the root of the app state, which is something completely different.)

wilkerlucio11:11:05

I noticed that ident queries doesn't seem to be normalized when reading, I did an expansion on the thinking links making the user a component with an ident, it didn't got normalized

thomasdeutsch11:11:39

As a datascript user - i think i have to reimplement db->tree for datascript. I can not use d/pull as a replacement, simply because [(:my-fn {arg: "x"})] and the new [[:root-key _]] is not a valid pull syntax. I was wandering - why is db->tree not based on the expr->ast from the om parser?

griffio11:11:11

@thomasdeutsch: "As soon as you try to enter a character into the input box, the reader :input-handler will get called twice.ā€ I observe this too. The first read is from the Key press - React event handler dispatch - the second comes from the om.next animate request frame ā€œloopā€ as it schedules a re-render.

r0man12:11:29

Hello, can someone point me to an example of something similar to the normalization tutorial where the content from :list/one and :list/two comes from a remote? I have a bit of a problem understanding how remotes and normalization plays together.

griffio12:11:03

@r0man: Don't think there is an exact example. Recommend going through all tutorials first, if not done so, as the answer is there. You can checkout the community examples at the end of the page https://github.com/omcljs/om/wiki#om-next Depends on what data format you are working with? The list data that you see in the example can be returned in transit format from the 'remote' middleware side. The normalization happens when the reconciler loads the list data from the :send function in the reconciler. The reconciler will only normalize 'raw' data by default like the example. So, you need a :send function to fetch the list data. I have some simple examples of loading data from a resource file - if required.

r0man12:11:23

@griffio: Thanks, I read the tutorials. Watching tony kays video at the moment. Looks like there is some info in it. I'll come to you back later maybe ... simple_smile

griffio12:11:56

@r0man: no problem - you are only a few steps from understanding that it is quite simple!

dnolen13:11:56

@thomasdeutsch: pull isnā€™t generic enough to do everything anyway, so how would db->tree using the AST help you? Curious what you have in mind.

dnolen13:11:15

@wilkerlucio: I think you mean de-normalized. Yes we wonā€™t do that automatically since we donā€™t know what that thing is. We only de-normalize if we have a query to drive. So if you want that you need to supply that.

dnolen13:11:44

@thomasdeutsch: Iā€™m also thinking you can solve this problem with remotes possibly? This might allow you do divide up the query into parts you can handle and those that need special treatment.

thomasdeutsch13:11:47

@dnolen: i need to think about it.

dnolen13:11:28

@thomasdeutsch: yes let me know what think

thomasdeutsch13:11:37

@dnolen: I have not looked into remotes at this point, so i do not know how i can embrace its functionality. I also have the option to query the schema for idents, and other crazy stuff - want to get some ideas from this blogpost, too: http://blog.juxt.pro/posts/datascript-dom.html

danielstockton14:11:23

what does AST refer to in an om context?

dnolen14:11:38

the query expression Abstract Syntax Tree

danielstockton14:11:39

which is the parsed query expression? is it exposed somewhere? as a user of datascript, i guess it's irrelevant

dnolen14:11:14

@thomasdeutsch: I also wonder if this is a problem DataScript users actually have

dnolen14:11:37

it seems to me you can do this stuff just by being OK with a Schema thatā€™s different on the client from the server

dnolen14:11:46

and including client only datums

dnolen14:11:27

@danielstockton: it is exposed and is useful even for DataScript users if you have real remote services you need to communicate with

danielstockton14:11:05

remote services which aren't using datomic where you need a parsed respresentation?

thomasdeutsch14:11:48

i think in most cases, the client db schema will be different from the server schema - and i do not see this as a problem.

danielstockton14:11:00

@thomasdeutsch do you just transact what the remote sends back into datascript or do you have a more sophisticated way of keeping client/server in sync?

dnolen14:11:29

@thomasdeutsch: right so this feature may not matter for you at all simple_smile

dnolen14:11:48

I never really expected we could just hide details of the store

dnolen14:11:58

just that pluggability would be possibility

thomasdeutsch14:11:01

@danielstockton: in previous apps, i simply transacted the data into the db. but i have not worked with om.next remotes yet, so i do not know if there is a challenge involved.

dnolen14:11:12

@danielstockton: the pattern that Iā€™ve seen

thomasdeutsch14:11:23

@danielstockton: have you tried to convert the example from @griffio to datascript?

dnolen14:11:42

so far is that people talk to Datomic, since a lot of the schema is just the same they can transact the entity tree into DataScript

dnolen14:11:59

Om Next supplies a :merge hook for this case

danielstockton14:11:37

@thomasdeutsch: No, but i will when i get a chance. Unfortunately I'm a part time om/cljs enthusiast trying my best to keep up alongside other things simple_smile

danielstockton14:11:28

currently my remote mutate methods transact and i return the transacted datums to the frontend, where i have a merge hook which just transacts them

danielstockton14:11:57

havent solved the tempids problem, still getting familiar with datomic/datascript so im not even sure how i'd update the db/id to match the backend

txus14:11:07

Iā€™m using componentWillReceiveProps to re-render part of a map (using leaflet.js). However, when I om/transact! to change the data, the transaction works (and I hint a read with {:keys [:my-toplevel-data-thing]}, but WillReceiveProps receives always the previous props, not ones that happen as a result of the mutation. Am I missing something regarding the lifecycle?

txus14:11:30

if I transact again, then the willReceiveProps gets the ā€œcorrectā€ props, just one transact too late

dnolen14:11:28

@txus just sounds like a bug

txus14:11:48

hm, ok, will try to reproduce it then

anmonteiro14:11:00

@txus: you on latest alpha? I have been using willReceiveProps recently and they were OK

txus14:11:22

using alpha24 yeah

txus14:11:48

I guess Iā€™ll find out reproducing a tiny example, maybe I missed something

txus15:11:39

thereā€™s code and screenshots

txus15:11:46

very strange, but then again i might be missing something

txus15:11:57

seem actually that the transacts are delayed always one transact

dnolen15:11:10

@txus the example is small enough please just put all of that into a GitHub issue, thanks!

dnolen15:11:24

will take a look over the weekend

txus15:11:33

great šŸ˜„

danielstockton15:11:04

@txus nice colourscheme, very retro

r0man16:11:41

@griffio: Ok, I watched that video, but things are still not working as expected. I pass a state atom with :normalize true to the reconciler. The state atom contains at the beginning denormalized data. After add-root! it is normalized as expected. So far so good. Now I try to fetch data from a remote via transit and get a list of results (not yet normalized). How do I get this data into my atom in a normalized way. If I just pass that data to the callback it overwrites my previously normalized data in the atom with the demormalized list I got from the remote. Any idea?

griffio16:11:35

@r0man: I pushed the list example you mention but using remotes, two remote lists. Have a look first and see if anything makes sense! Here https://github.com/griffio/om-next-05

r0man16:11:11

@griffio: Thanks, I'll take a look

anmonteiro16:11:22

so I'm also getting @txus 's issue after all

dnolen16:11:41

@r0man: you will need to supply your own :merge if you need some kind of deep merge

dnolen16:11:58

the default implementation is intentionally naive

r0man17:11:18

@dnolen: Do you mean :merge-tree like here https://github.com/griffio/om-next-05/blob/master/src/om_next_05/core.cljs#L134 ? Or is :merge something else?

r0man17:11:00

ah, ok. I see, there's :merge and :merge-tree

tony.kay17:11:54

@griffio: I think you might be misunderstanding remotes

tony.kay17:11:58

looking at your example

tony.kay17:11:26

You don't list the data keys you want to deal with remotely...you list the remote hosts you want to talk to.

tony.kay17:11:36

@r0man: I thin you might just want :merge-tree for what you're doing...`:merge` would be a lot more work than you want. I think some renaming happened at some point...hard to keep track simple_smile

griffio17:11:46

@tony.kay: ok thanks for the pointer understood - the example there is just get data in one single time to merge-tree.

tony.kay17:11:21

yeah, I just didn't want that misleading anyone else who might go look at the example for instruction on remotes

juhoteperi18:11:46

I'm having a problem transact! on alpha24, looks like the reads in transaction do nothing

juhoteperi18:11:54

Perhaps a problem with transform-reads?

(om/transform-reads reconciler `[(links/like {:link-id "1"}) [:links/by-id "1"]])
; => [(links/like {:link-id "1"})]

juhoteperi18:11:43

Or perhaps that works as it should and I just don't know what it should do

thomasdeutsch18:11:42

@dnolen: what was the design decision, to ignore [(:my-fn {param: "x"})] in db->tree ? Was it, because query-fns should only be called after the component was mounted (received props?)

dnolen18:11:12

If you use db->tree you've bottomed out, should not expect any of that stuff to work

r0man18:11:24

@griffio and & @dnolen: I found my problem with normalization and remotes. My data was coming back from the remote as a list, and not as a vector. Normalization didn't kick in. When returning my data as a vector it's working. '{:spots/list [{:id 1} {:id 2}] vs. '{:spots/list ({:id 1} {:id 2})

r0man18:11:02

Should normalization also work on lists, like the second case?

dnolen18:11:57

@r0man: no list support

r0man18:11:32

@dnolen: ok, maybe worth adding to the normalization tutorial. do you mind if I add a note like this?

r0man18:11:42

@dnolen: I added a note to the tutorial, but I'm curious. Why no list support? Are lists reserved for anything special?

dnolen19:11:25

Just don't care about

johanatan22:11:43

Does anybody know the React Native or Om way to restore UI controls' values (e.g., textinput text) upon changing back to a previous screen? I tried setting 'value' but then the cursor gets moved to before the beginning of the text after each character the user actually enters in the box [as there's no way to determine if the current render cycle is due to a) changing back to the screen from another 'modal'/popup if you will or b) the user actually entering text]). I tried a workaround where I kept some side state in another atom (that isn't being observed by Om Next) to store whether a screen change was occurring or not and that worked but only for the first render cycle-- if the user did something else on the page after changing back to the screen (like say checking a checkbox), then the side state had been cleared and my logic didn't set the 'value' of the textinput to that stored in app-state. I'm now considering an alternative workaround that should work (i.e., setting the 'value' of the textinput to the text stored in my big atom on every render except those triggered by an onChange event in the actual textbox in question); however, the idea of having 'side-state' in a 'side-atom' seems to go against the Om way.