om

Please ask the channel first, not @dnolen directly!
danburton 2017-04-27T01:20:53.137771Z

Suppose I have an om.next SPA. The send function forwards queries to the server, and the server interprets the om.next query as appropriate. This works just great for reads. But now what we want to do is server-side mutations. Is using (om.next/transact! c '[(server-mutation!)]) an appropriate way to initiate something like this? We can't figure out how to write a (client-side) mutate parser function in the same way that we write our read parser function: in such a way that it will instruct the reconciler to send the mutation to the server for interpretation server-side.

danburton 2017-04-27T01:23:45.160735Z

Come to think of it, are there any simple examples of using om.next for a plain old CRUD app?

matthavener 2017-04-27T03:36:32.153928Z

@danburton: yup, that transact! call looks correct

matthavener 2017-04-27T03:36:54.156245Z

as for sending, you just return {:remote true} from your mutate parser function

twashing 2017-04-27T17:00:15.028026Z

Hey @matthavener , thanks for the response. We’re doing exactly that.

twashing 2017-04-27T17:00:20.029585Z

(defmethod mutate 'my/key
  [{:keys [state ast]} k param]
  {:action (fn [] (swap! state (fn [v] (assoc v k param))))
   :remote true})

twashing 2017-04-27T17:01:28.057897Z

But the send function isn’t being fired when we make a call like.

twashing 2017-04-27T17:02:17.076514Z

(om/transact! reconciler ['(my/key {:foo :bar})])

petterik 2017-04-27T17:33:52.780307Z

@twashing Are you passing anything to the :remotes key of the reconciler?

petterik 2017-04-27T17:34:17.789574Z

when calling (om/reconciler)

macrobartfast 2017-04-27T18:55:05.638762Z

are there any om next oriented tutorials like those in the book Learning Clojurescript?

macrobartfast 2017-04-27T18:55:58.659169Z

seems like most of the tutorials are oriented to the old version of Om, and as noob really can't figure it out.

macrobartfast 2017-04-27T18:56:44.676598Z

it's so different it seems like it should really gotten a new name (at least that would have allowed for me to figure out which documentation/tutorials are current).

claudiu 2017-04-27T20:00:29.008232Z

@macrobartfast noob here also just starting to get the hang of it.

claudiu 2017-04-27T20:01:30.031675Z

https://github.com/omcljs/om/wiki under om.next

anmonteiro 2017-04-27T20:04:09.088096Z

I feel like people don’t find these too easily, but the devcards examples in the Om repo are also a nice example of how to write simple Om Next applications: https://github.com/omcljs/om/tree/master/src/devcards/om/devcards

claudiu 2017-04-27T20:07:23.154654Z

@anmonteiro thank you. totally missed the devcards 🙂

macrobartfast 2017-04-27T20:35:39.738886Z

@anmonteiro thank you for suggesting devcards.

macrobartfast 2017-04-27T20:40:19.835909Z

@anmonteiro looking through the code at https://github.com/omcljs/om/blob/master/src/devcards/om/devcards/tutorials.cljs is helpful... is there a companion post or are there instructions for getting this running?

anmonteiro 2017-04-27T20:41:13.854342Z

@macrobartfast that’s the code for the tutorials in the Wiki https://github.com/omcljs/om/wiki#om-next

macrobartfast 2017-04-27T20:41:28.859568Z

ah, right... doh!

macrobartfast 2017-04-27T20:41:30.860398Z

thanks.

currentoor 2017-04-27T20:45:38.945461Z

Anyone ever run into a situation where follow on reads (keywords at the end of a mutation literal) don’t cause the appropriate re-render?

macrobartfast 2017-04-27T21:03:11.305870Z

I really need some help here. I just want to get a basic CRUD app up in Om or Om Next. The tutorials are fantastic (thank you for everyone who worked on them) but the introductory ones seem to stop before a CRUD implementation, and the more advanced ones seem designed to skip over a basic CRUD implementation to focus on the cool features of ClojureScript or Om. I'd really like to see a DB backed CRUD as opposed to an atom. A lot of tutorials seem to just use an atom as opposed to a database in the interest of brevity. At least one uses Datomic, which is cool, but a bit of a step for a beginner. There are of course implemented ToDo apps, but they don't come with tutorials, and it's hard to tell if they are current. I'll hopefully be able to contribute this once I learn it, but there's a catch 22 at this point. There are books, but they seem to be anywhere from a year to four years old and are broken by recent changes. I fully acknowledge my limitations, but it seems like you have to be proficient in clojurescript to get going in it.

macrobartfast 2017-04-27T21:04:21.329163Z

So, can anyone suggest a DB backed CRUD tutorial/book/article that's current? Or can someone just give me a basic end-to-end idea of what I can piece together?

macrobartfast 2017-04-27T21:07:14.384204Z

I think I need the equivalent of what a senior developer would tell an intern on their first project (i.e. use this for your front-end, use this for your database, tie them together with this...)

wilkerlucio 2017-04-27T21:07:18.385662Z

@macrobartfast I recommend you check the Untangled video tutorials: https://www.youtube.com/playlist?list=PLVi9lDx-4C_T_gsmBQ_2gztvk6h_Usw6R

macrobartfast 2017-04-27T21:07:47.395276Z

As you mentioned that I was just typing out that untangled is too advanced and complex for me right now...

wilkerlucio 2017-04-27T21:08:00.399150Z

you will end up using the local atom anyway, this is your local representation, I guess what you are missing is how to integrate with remotes (server side), so the untangled tutorials have some coverage on it

wilkerlucio 2017-04-27T21:08:25.406669Z

Untangled is just a layer on top of Om.next, it implements stuff you would have to do anyway (like a local parser)

macrobartfast 2017-04-27T21:09:48.432530Z

which is the problem (and please forgive what may seem like a lack of gratitude for your suggestion)... Untangled just obfuscates what I don't understand to start with...

macrobartfast 2017-04-27T21:10:10.439461Z

it seems like it will be awesome, when I understand it...

wilkerlucio 2017-04-27T21:10:18.442139Z

had you gave the videos a try? the Untangled videos are targeted for people new to Om.next too

macrobartfast 2017-04-27T21:10:39.448773Z

I'll take a look again. I started watching them a month ago, but I should revisit them.

macrobartfast 2017-04-27T21:11:20.461265Z

thanks for your time and suggestions!

wilkerlucio 2017-04-27T21:15:48.543137Z

no worries, please ask again if you can't figure it out, it just need some time to get in your head 😉

macrobartfast 2017-04-27T21:18:33.592648Z

thanks 😀

macrobartfast 2017-04-27T21:19:24.608298Z

to be honest, I had forgotten about untangled (and had to go learn more of the basics)...

macrobartfast 2017-04-27T21:19:46.614719Z

and when I was looking at it they were very friendly and helpful in their slack channel.

twashing 2017-04-27T21:50:36.127272Z

@petterik I have something like the below. That send isn’t getting fired, and I don’t know why.

twashing 2017-04-27T21:50:45.129662Z

(let [v-prime (assoc v :foo :bar)

      send (fn [{:keys [remote]} cb]
             (cb v-prime))

      parser (om/parser {:read read :mutate mutate})

      reconciler (om/reconciler
                  {:parser parser
                   :send    send
                   :remotes [:remote]
                   :state main-menu})

      state {:state (om/app-state reconciler)}

      r (parser state [:treasury.manual-money-movement/create])]

  (empty? r))

macrobartfast 2017-04-27T21:57:12.228308Z

@wilkerlucio the untangled videos are actually great... I just didn't know enough when I tried to watch them last time.

1
twashing 2017-04-27T23:15:01.183346Z

In an Om.next app, are we allowed to do :remote mutations?