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.
Come to think of it, are there any simple examples of using om.next for a plain old CRUD app?
@danburton: yup, that transact!
call looks correct
as for sending, you just return {:remote true}
from your mutate parser function
Hey @matthavener , thanks for the response. We’re doing exactly that.
(defmethod mutate 'my/key
[{:keys [state ast]} k param]
{:action (fn [] (swap! state (fn [v] (assoc v k param))))
:remote true})
But the send
function isn’t being fired when we make a call like.
(om/transact! reconciler ['(my/key {:foo :bar})])
@twashing Are you passing anything to the :remotes
key of the reconciler?
when calling (om/reconciler)
are there any om next oriented tutorials like those in the book Learning Clojurescript?
seems like most of the tutorials are oriented to the old version of Om, and as noob really can't figure it out.
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).
@macrobartfast noob here also just starting to get the hang of it.
https://github.com/omcljs/om/wiki under om.next
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
@anmonteiro thank you. totally missed the devcards 🙂
@anmonteiro thank you for suggesting devcards.
@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?
@macrobartfast that’s the code for the tutorials in the Wiki https://github.com/omcljs/om/wiki#om-next
ah, right... doh!
thanks.
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?
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.
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?
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...)
@macrobartfast I recommend you check the Untangled video tutorials: https://www.youtube.com/playlist?list=PLVi9lDx-4C_T_gsmBQ_2gztvk6h_Usw6R
As you mentioned that I was just typing out that untangled is too advanced and complex for me right now...
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
Untangled is just a layer on top of Om.next, it implements stuff you would have to do anyway (like a local parser)
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...
it seems like it will be awesome, when I understand it...
had you gave the videos a try? the Untangled videos are targeted for people new to Om.next too
I'll take a look again. I started watching them a month ago, but I should revisit them.
thanks for your time and suggestions!
no worries, please ask again if you can't figure it out, it just need some time to get in your head 😉
thanks 😀
to be honest, I had forgotten about untangled (and had to go learn more of the basics)...
and when I was looking at it they were very friendly and helpful in their slack channel.
@petterik I have something like the below. That send
isn’t getting fired, and I don’t know why.
(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))
@wilkerlucio the untangled videos are actually great... I just didn't know enough when I tried to watch them last time.
In an Om.next app, are we allowed to do :remote
mutations?