Fork me on GitHub
#om
<
2016-03-16
>
tomjack03:03:56

cljs.user=> (om/focus-query '[{:items [:id :type {:comments [:id]}]}] [:items :comments])
[{:items [{:comments [:id]}]}]
cljs.user=> (om/focus-query '[{:items {:post [:id :type {:comments [:id]}]}}] [:items :comments])
[{:items {:comments nil}}]
cljs.user=> (om/focus-query '[{:items {:post [:id :type {:comments [:id]}]}}] [:items :post :comments])
[{:items {:post [{:comments [:id]}]}}]

tomjack03:03:32

this makes it seem like union keys should be in paths

tomjack03:03:31

but it is impossible for path-meta to put them there, isn't it?

urbanslug05:03:34

@dnolen: Just want to say hey. I’m a big fan.

urbanslug05:03:02

@tawus: Thanks, will look into it.

tomjack06:03:44

bug for parameterized unions? if the params in Blog's query are removed, the problem goes away

cjmurphy07:03:28

I have a grid UI structure. All the cells are the same Om Next component - and that component's job is to render a checkbox. When a user clicks om/transact! happens. For what is read afterwards (last param to om/transact) I have put in the :id of the component. There are a lot of these checkboxes, and every time one is clicked either on or off, they are all re-rendered. This is despite the fact that only one of them has changed. But it makes sense because they all have the same :id. I tried to put (om/get-ident this) as the last argument to transact!, but that didn't work. Is there a way around this unnecessary rendering?

tomjack08:03:16

what happens if you put nothing there?

urbanslug08:03:18

@tawus: I would rather not use jquery

urbanslug08:03:36

I’m surprised Om just doesn’t have anything for it.

urbanslug08:03:57

I guess a plugin would do a lot of good.

urbanslug08:03:32

thiagofm: To show upload progress but again that’s not anywhere near the core purpose of Om

cjmurphy08:03:53

@tomjack: Putting nothing there - good option, and makes sense - this is what needs to be re-rendered. If I put nothing there (in last arg to transact) then the check boxes don't get re-rendered, not right away. But there's an effect waiting, because when I go to say another tab and come back, then the checkboxes become un/ticked as they should be. (And still all get rendered, not just the changed ones). I tend to always put something in the last arg to transact, because I've never seen it work as I think it should, which is to re-render the current component (this) immediately. It is because the component is a (React defined) 'controlled component' (has no state of its own), that it is relying on Om Next.

thiagofm09:03:13

urbanslug: I think it fits nicely the purpose of separate package/component

tawus09:03:38

@urbanslug: You don’t have to. There are plain javascript file upload scripts too. Even there are html5 based react upload components which are plug-n-play with om simple_smile

urbanslug09:03:35

WOW really? hmm let me look into that. I’m quite confused. I haven’t even totally understood clojure.

tawus10:03:58

@urbanslug: then om can be an uphill task 😬

urbanslug10:03:18

It is but I am fast learner.

tawus10:03:51

@cjmurphy: transact for me rerenders too much simple_smile It renders the parent too or atleast that is what seems to happen for me.

doddenino10:03:16

@tony.kay: Amazing, thanks a lot! simple_smile I'm getting an exception when trying to start the server with (go), but it's probably my noobness

anmonteiro11:03:43

@cjmurphy: have you looked into path optimization? If you have idents that should work

jannis12:03:42

@tony.kay: Nice. Just saw the untangled announcement. simple_smile

urbanslug13:03:11

@dnolen: Hello simple_smile very glad to "meet" you.

dnolen13:03:05

@urbanslug: the same, welcome to the channel simple_smile

urbanslug13:03:27

Would migrating code from Om now to next all at once break stuff?

urbanslug13:03:35

Is it backward compatible?

urbanslug13:03:06

@dnolen: Maybe I should read the docs more before coming to this channel with questions.

urbanslug13:03:21

*some questions

urbanslug13:03:46

Also I noticed the failure to define what a component is in the Om wiki so I went ahead and added one, not sure if it’s wrong because I lack experience with react. https://github.com/omcljs/om/wiki/Conceptual-overview#components

urbanslug13:03:21

I really had an issue with that.

dnolen14:03:06

@urbanslug: not backwards compatible - that’s a longer term goal

dnolen14:03:50

well some kind of bridging is a goal

dnolen14:03:55

backwards compatibility not a goal

dnolen14:03:49

that said, we’ll try to maintain both old and next in the same repo for the forseeable future

urbanslug14:03:17

True because they are radically different. I hope porting the code won’t break too much. Also I’m thinking long and hard about property based testing for async in Om Next.

urbanslug14:03:34

But to be honest I’m fearful that it’s too grand a task to take on.

urbanslug14:03:25

There are a lot of async processes going on in our project and I would like to test them because currently it’s been pushed forward.

dnolen14:03:03

migrating a big project is going to be challenging for sure

urbanslug14:03:08

dnolen: Do you test your async calls?

dnolen14:03:34

yes - but that’s not specific to Om

urbanslug14:03:22

Yes, I understand that. Currently planning on figuring it out with phantomjs. Okay, I’m veering offtopic.

gary14:03:43

@urbanslug: try porting a huge webapp with jsps, hibernate, and random bits of javascript everywhere to Om and then you'll see how good you've got it 😃

urbanslug15:03:11

@gary: What about the already huge app that I’m working on though?

urbanslug15:03:43

Not to mention that I am very new to clojure, cljs Om React literally everything.

gary15:03:16

@urbanslug: I was just kidding, please don't do what I said because that is what I'm working on

urbanslug15:03:59

@gary: I am not even familiar with the tools you’re talking about. Tell me about them.

gary15:03:04

Those are the tools from the Enterprise Java world

seanirby15:03:22

So i'm kind of confused about how to structure initial data. Is it supposed to already be shaped like the UI tree when passed into the reconciler or are you supposed to setup your queries and read functions so they read the flat data.

gary15:03:55

@urbanslug: I'm working on something to help Java EE developers transition to Om so you're not my target audience 😃

urbanslug15:03:41

@seanirby: Have you looked at IWillMount? Not sure if the same functions in Om Now are in Om Next.

urbanslug15:03:28

seanirby: You then use cursors to reach into the app-state (i.e the global data map)

seanirby15:03:36

urbanslug: im using om next

urbanslug15:03:55

@gary: WOW uh I have no Java background.

urbanslug15:03:37

@gary: I am not. No enterprise has touched me yet.

urbanslug15:03:39

seanirby: Yeah, can’t help you there everything in https://github.com/omcljs/om/wiki/Documentation-(om.next) looks new.

cmcfarlen15:03:21

@seanirby: parser :read functions will read from the normalized db and return normalized values. You can use db->tree to convert. Merged novelty should be denormalized and the reconciler will normalize it based on the root query

cmcfarlen15:03:53

@seanirby: err, read fns return de*-normalized values. sorry typo

tony.kay15:03:25

@doddenino: Make sure you follow the instructions on making a config file. The error message for that is better in the next release of server.

seanirby15:03:36

cmcfarlen: I thought what read returns depends on your implementation?

cmcfarlen15:03:25

@seanirby: certainly, but the shape of the data is based on the query, so if you are using the default normalized state layout, then you can use db->tree as a utility to shape the data.

cmcfarlen15:03:57

If your implementation doesn't use the default format, then you have to shape the data in the read fn if necessary

seanirby15:03:00

cmcfarlen: I think I follow. Basically use db->tree as a way to convert your query into UI tree data thats in the same shape as the query?

seanirby15:03:37

(provided you're using the normalized state layout that is)

seanirby15:03:33

cmcfarlen: thanks! im gonna try that out.

cmcfarlen15:03:03

@seanirby: there is good info here on parser fn details and responsibilities: https://awkay.github.io/om-tutorial/

seanirby15:03:34

cmcfarlen: so if you're doing that, that means you can't rely on Om's auto normalization?

matthavener15:03:16

using om’s db->tree goes hand-in-hand with auto normalization, because db->tree expects the db in the om defined normalized format

anmonteiro16:03:56

Hey everyone, I'm very pleased to announce Cellophane, a server-side rendering library for Om Next. Check it out in the link below, and don't hesitate to ask any questions. https://github.com/ladderlife/cellophane

cjmurphy16:03:48

@anmonteiro: path optimization seems to be for when there's a speed problem, which I don't have. I want an object to be re-rendered rather than a class. Are we supposed to be able to put Idents at the end of a transact call? It is definitely the case that 'other things' are effected by the mutation, so I do actually need to use the 'last param' of transact call (i.e. can't rely on the query).

anmonteiro16:03:36

@cjmurphy: yes you can use idents at the end of a transact! call

anmonteiro16:03:45

if that doesn't work it's a bug, I've seen it work before

anmonteiro17:03:25

@jlongster: definitely, we need the same kind of behavior in the JVM

anmonteiro17:03:00

it's something that could eventually become part of Om

jlongster17:03:39

@anmonteiro: yeah, seems hard to maintain, but nice work! When I was working on my app I just use CLJS on the backend as well simple_smile

anmonteiro17:03:30

@jlongster: well you can definitely use React's renderToString then

anmonteiro17:03:44

this is targeted at people using Clojure in the backend

anmonteiro17:03:16

definitely hard to maintain for the time being

anmonteiro17:03:07

probably more than foam since Om Next is still in active development

jlongster17:03:55

nice to have for others I'm sure

dnolen17:03:01

@anmonteiro: looks useful, might be nice to start a wiki page of things that would need to be done to fold that in that I can review

anmonteiro17:03:43

@dnolen: Dully noted, I'll get to it soon. This is mostly based on the Foam concept

anmonteiro17:03:54

lots of things will be the same

anmonteiro17:03:11

But I've built on it to generate markup that React can pick up on the client!

dnolen17:03:21

I’m pretty much 100% behind the Foam thing, esp. now that react-id is history

anmonteiro17:03:38

FWIW, Cellophane still generates reactids

anmonteiro17:03:23

(still) à la React 0.14

dnolen17:03:25

to be expected simple_smile

anmonteiro17:03:02

I'm quite proud of the fact that it can generate markup which React picks up on the client side

anmonteiro17:03:43

some reverse-engineering was needed there, attribute order, supported attributes (camelCase stuff, etc.) and other stuff

anmonteiro17:03:45

and, when everything was sorted out, still needed to wrap everything in an extra div or the checksums wouldn't match

anmonteiro17:03:10

@dnolen: there are also some hacks in Cellophane in order to support Om Next statics... ATM I'm creating Clojure records for components and multimethods that dispatch on those classes for queries, params and Idents. I resorted to this approach because I couldn't find a way to have static methods in defrecord Any alternative suggestions are deeply appreciated

dnolen17:03:36

yeah there’s just no way to do that in Clojure

dnolen17:03:18

static methods

anmonteiro17:03:41

creating Clojure records (which generate Java classes) also introduces the limitation of having to use :import in the ns macro

anmonteiro17:03:55

:require is not enough

dnolen17:03:28

yes if you want to import the record directly instead of a factory fn

anmonteiro17:03:51

yes, it was necessary e.g. in the TodoMVC example

anmonteiro17:03:00

where you (get-query todo/Item) which is in another ns

anmonteiro17:03:28

(for context: i've added that TodoMVC example as a full-stack example with server-side rendering to the repo)

dnolen17:03:12

hrm right, yeah something to think about

anmonteiro17:03:33

anyhow, I'll work on some design doc in the next few days and add it to the wiki

dnolen18:03:02

cool, thanks would be helpful, thanks

iwankaramazow19:03:09

@anmonteiro: awesome work with SSR!