# om

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

nano 01:57:08

Anyone have any example of passing a query to the cb function that's passed to the reconciler send function? Not sure what it's supposed to do. Say if I have app-state {:foo {:bar 42 :baz 23}} and my reconciler send wants to update :baz, would (cb {:baz 99} [:foo]) be a correct call?

pupeno 13:47:24

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

cjmurphy 13:52: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...

cjmurphy 13:53:11

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

pupeno 13:53:50

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

pupeno 13:54:20

Argh, it uses boot.

cjmurphy 13:55:03

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

pupeno 13:55:24

What do you mean you made it?

cjmurphy 13:56:46

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

pupeno 14:13:41

It doesn’t seem to be stateful.

cjmurphy 14:17:21

All state is in the Client.

cjmurphy 14:18:22

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

pupeno 14:18:29

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

cjmurphy 14:19:40

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

pupeno 14:28:53


r0man 16:57:26

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.

stuartsierra 18:32:17

Are there any archived logs of this or other channels?

stuartsierra 18:40:28

@taylor.sando: thanks!

pupeno 18:49:19

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

petterik 18:50:06

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

petterik 18:50:08


pupeno 18:50:18


mdhaney 20:55:02

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

hueyp 20:55: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

hueyp 20:56: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

hueyp 20:56:35

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

hueyp 20:57: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

mdhaney 21:03: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.

mdhaney 21:06: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.

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

r0man 21:13:25

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

mdhaney 21:15: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.

mdhaney 21:19: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.

r0man 21:19:40

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

mdhaney 21:25: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.

mdhaney 21:26: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.

r0man 21:27: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