Fork me on GitHub
#om
<
2016-02-06
>
Pablo Fernandez11:02:24

Is this a good example to try to wrap my head around Om Next: https://github.com/swannodette/om-next-demo ?

cjmurphy11:02:11

It may have been updated recently, otherwise does not work, so good to read only. What helped me the most was the Kanban demo. But there are now quite a few around...

cjmurphy11:02:11

The Kanban one shows a 'big application', so is a contrast to all the tutorials which concentrate on the mechanics.

Pablo Fernandez11:02:50

That sounds like what I want. I’ll check it out. I’m particularly interested in server syncronization.

Pablo Fernandez11:02:20

Argh, it uses boot.

cjmurphy11:02:03

I made it use lein b/c I'm on Windows and it GenSym-ed on me.

Pablo Fernandez11:02:24

What do you mean you made it?

cjmurphy11:02:46

I put in a project.clj file so it would work with figwheel

Pablo Fernandez12:02:41

It doesn’t seem to be stateful.

cjmurphy12:02:21

All state is in the Client.

cjmurphy12:02:22

I meant PermGen error (I was reading about macros and not concentrating) simple_smile

Pablo Fernandez12:02:29

I see. Is there an example that does client-server synchronization that I could play with?

cjmurphy12:02:40

steve8 or similar name did some good things. I'm not at that stage yet. I'll try to find...

r0man14:02:26

Hello, I'm trying to build a login form with om.next. I would like the user to enter a username and password, which should be validated on the server. If the username and password is correct I would like to return an access token and merge this back into my app state. I'm not quite sure if I should use a parameterized query for that or a remote mutation fn. For the parameterized query I can see how the returned data is merged into the app state, but I'm not quite sure how to merge the result of a mutation fn into my app state, since what I get back from a mutation fn looks quite different than what I get from a query. Does anyone have an example app that does something similar, or any hints? Thanks.

Lambda/Sierra16:02:17

Are there any archived logs of this or other channels?

Pablo Fernandez16:02:19

What’s the name of that alternative syntax for html? What’s the name of the library?

petterik16:02:06

Talking about syntax like: (html [:div [:p "stuff"]]) ?

mdhaney18:02:02

For anyone interested, I also tested kioo (enlive style templating) and it works fine with Om-next.

hueyp18:02:07

the discussion yesterday about synthetic keys and that you only want them for top level … you also can’t link to them right? e.g. if :user/todos is a top level key, you can make the parse method do whatever you want … but if its also linked from :current-user, then you need to modify the :current-user top level key as well to handle any queries with :user/todos

hueyp18:02:07

I feel like I keep getting pulled in the direction of having a second interior parser and then only a few top level keys in the actual parser

hueyp18:02:35

basically re-implementing db->tree but with the ability to 'plug in’ logic on certain keys

hueyp18:02:52

some examples in the tutorial call parser recursively and put a ‘current’ object in it … but I feel like that is kind of mixing top-level and non-top level keys in the same thing

mdhaney19:02:59

@r0man: I started off trying to do authentication as you mentioned, but found it better to do it outside of Om-next. I make a separate REST call to our IDM system, then store the token in a separate atom from my app state. Then my send function grabs the token and adds the auth header for every outgoing request. This was easier than ensuring every remote query included the token. Hopefully that makes sense. If you're still stuck, I can try to pull out the essentials into a gist, but it might be a day or two before I can get to that.

mdhaney19:02:48

Oh yeah, I also set a flag in my app state as to whether or not the user is logged in (so the UI can adjust accordingly). You could set the token as well, I just didn't need the actual token for the UI itself.

r0man19:02:42

@mdhaney: Thanks, that might also be an option. However I'm looking in general for an example that sends form fields to the server, the server validates the data, sends back an error message on a failure or does something when data is valid. And how to react on those 2 cases within om.next. I think I'm looking for an example of a general send function that handles errors as well.

r0man19:02:25

I think I stuggle with how to merge the response of a mutation into app state, and do something depending on the result

mdhaney19:02:34

@r0man: yeah, there are lots of ways to do it. The main point I wanted to make was that if the token is in your app state, you'll have to ensure that all your remote queries end up with the token, since most of the time you need to set a header with the token in your send function.

mdhaney19:02:01

Our system is more complicated too, because our IDM system redirects to a particular url and passes the token as a request param, like Oauth. So for that you need routing in place as well. Not everyone will have all these requirements, but in corporate environments it's pretty common.

r0man19:02:40

@mdhaney: yes, understood. My plan was to pass the state to my send function and fish the token out there on each request

mdhaney19:02:08

How are you planning to pass the state? Send gets called with a map of remotes->queries and a callback. You'll probably have to make sure your app state is in an atom and either access it directly or close over it when you create your send function. And be sure to set :normalize to true on the reconciler, since by default normalization is turned off when you pass it an atom.

mdhaney19:02:52

Actually, I think I have a commit on a branch where I did it almost exactly like you're saying. I'll see if I can track it down.

r0man19:02:26

haven't thought about it too much, but yes I use a state atom, use :normalize true and access the state from my send function

domkm21:02:28

Is there a description of the differences between Om Next, GraphQL/Relay, and JSONGraph/Falcor? I remember seeing or reading about it but I can't recall where.

dnolen21:02:43

@domkm: there’s nothing written up that enumerates all the differences

domkm22:02:27

@dnolen: Ah, okay. Thanks. I'd sure love to see a comparison.

dnolen22:02:30

@domkm: I’m sure someone will write it up eventually

dnolen22:02:48

but the short story is that Om Next is exactly Relay/GraphQL + Falcor + HTTP cacheability

domkm22:02:28

@dnolen: Interesting, thanks. My (very limited) understanding was that GraphQL was typed. Is that accurate and would that be a difference from Om Next?

hueyp22:02:10

I’m probably going to write an ‘om.next from relay/graphql perspective’ thing as thats pretty much how I’m approaching stuff currently 😜

domkm23:02:57

@hueyp: Please do. simple_smile