Fork me on GitHub
Pablo Fernandez11:02:24

Is this a good example to try to wrap my head around Om Next: ?


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...


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.


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?


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

Pablo Fernandez12:02:41

It doesn’t seem to be stateful.


All state is in the Client.


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?


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


Hello, I'm trying to build a login form with 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.


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?


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


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


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


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


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


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


@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.


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.


@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 I think I'm looking for an example of a general send function that handles errors as well.


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


@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.


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.


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


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.


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.


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


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.


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


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


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


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


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


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


@hueyp: Please do. simple_smile