This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-25
Channels
- # aws (1)
- # bangalore-clj (9)
- # boot (97)
- # capetown (1)
- # cider (4)
- # clara (1)
- # cljs-dev (2)
- # cljsrn (109)
- # clojure (258)
- # clojure-finland (3)
- # clojure-greece (2)
- # clojure-italy (1)
- # clojure-russia (33)
- # clojure-spec (41)
- # clojure-uk (46)
- # clojurescript (57)
- # component (17)
- # core-async (6)
- # datomic (13)
- # devcards (10)
- # dirac (2)
- # euroclojure (1)
- # figwheel (1)
- # funcool (1)
- # hoplon (472)
- # luminus (17)
- # off-topic (1)
- # om (16)
- # onyx (40)
- # pedestal (14)
- # proton (12)
- # re-frame (27)
- # reagent (15)
- # ring-swagger (2)
- # specter (5)
- # testing (4)
- # untangled (258)
- # vim (4)
Whohoo return values for mutations (will be very useful for certain situations)
Hey everyone trying to use latest cljs: @wilkerlucio just sent me a PR that fixes Untangled to work with the latest Om/Cljs. I have applied it to develop branch, and pushed it to clojars as part of 0.6.0-SNAPSHOT
@tony.kay just fyi, I just tested compiling with the latest snapshot and it's working again, thanks for the release 🙂
hoping to get the forms stuff worked out as well this week. Too many things going on
nice, exciting times
@tony.kay what features you are looking for help on documenting?
@wilkerlucio like the new return value support
Make sure the new load
function is in data fetch, and note the deprecated load-data
.
@tony.kay ok, I'm still trying to catch up with all the new goodies, I would like to experiment a bit with the server-return, then I can help with some docs, do you have an example use case for the server return?
@wilkerlucio See the discussion above with jasonjckn (11:11am ysterday)
and a discussion of how/why. I made one change at the end of that discussion, so make sure you follow that 🙂
My coding guidelines around it are to make your return handler a multimethod, and co-locate the return handler with the mutation.
If I had control of the Om parser internals I probably would have made it an additional key on mutation methods (:value, :action, :return-action)
@tony.kay just to check if I'm getting it right, the :return
is something you can get back from a server mutation, and then it will be dispatched into a post-mutation to be handled on the client, is that correct?
@tony.kay perhaps the mutation results should trigger a mutation ? it seems like the untangled api is asymmetric, e.g. on mutation failure (tx/fallback) => trigger mutation, but on mutation success (mutation result) implement some global handler
@jasonjckn the problem is we only have the symbol that is already an Om mutation
e.g. here's symmetry: post-mutation: a mutation triggered to operate on recently changed local state mutation result: a mutation triggered to operate on recently interim state returned fallback: a mutation triggered to operator on error state
yah good points, oh well, i guess it's the best design right now, in theory, you could add (tx/mutation-result :action 'foo/bar)
if you co-locate the defmethods of mutate and handle-return, then the code is all right together
I suppose the 'real' API win would be the following:
(defmethod mutate 'foo/bar [..]
{:value {:keys []}
:action (fn [] ..)
:result-action (fn [] ..)})
If I had control of the Om parser internals I probably would have made it an additional key on mutation methods (:value, :action, :return-action)
ah yes
in clojure philosophy data is extensible, e.g. {:untangled/mutation-result ... :action ... :value ...}
@wilkerlucio might want to hold off on docs, I think we can do without the extra mmethod
also may be worth doing :fallback-action in the same place if that makes sense, you could keep both apis for backwards compatibility.
fallback is needed for exceptions. Don't know what went wrong, so they're not as easy to target
hm. This might not be the best idea, for other reasons. I have no AST or anything. So, if you write a mutation that wants to play with that stuff globally (e.g. to rewrite the params of a remote) it might crash
in theory you could pass the right env, you just don't know how to do build it up yet
it's just not easily available to you through om.next, the env still definitely makes sense in mutation results
@jasonjckn erm, :result-action
?
it's all okay but that name doesn't really highly it's the remote's action, not the local action
I'm sorta liking how it is currently implemented, partially because the env isn't the same (since we're no longer parsing a query)
and you want to be called after all of the merging is done...so this is the phase to run in
is there some conversation you can have with @anmonteiro about this
I'm kinda leaning towards my current solution again. I don't think this is something ppl are going to need a lot, and co-locating a clear mmethod next to your mutation really is pretty clean
does it make it easier if it's {:remote (assoc ast :action-result (fn [] ..) :action }
this seems like the right place for it, does this not give you some flexibility in the remote implementation to call the action-result handler when the remote action finishes?
yeah, I'm sticking with how I've implemented it. It's just too fragile and complected to add this into mutate, even though on the surface it looks like a good idea
untangled implements this remote right? so in the implementation, here's a shitty one, but you maintain a registry of mutation name->{action-result function , env, etc} then when merge comes back (or maybe there's some callback in remote) you use that registry, obviously this sucks, does it work? i'm not that familiar with om, but i feel like if it's doesn't already support this 'callback when remote mutation comes back' this seems like a logical flow of it's design
anyways if you ever think of some small change to om.next that would allow this to be internal niceness, definitely post an issue
i don't know the specifics of om, but just thinking about it generally it seems to flow at least in my mind, so maybe there's some small change they can make
whether that's env available in reconciler pluggable merge, or env available in remote mutation ajax cb, etc, etc
the whole constructions of invocations of parse has to do with the front-side of transactions, not the back-side
the results of parsing, e.g. the AST are needed both before remotes are contacted, and also after they're contacted, to for example normalize the returned data
so from that abstract view it would follow env should be available after remote returns with action-result
i understand the specific om.next api right now doesn't allow for that, but maybe there's a small change worth suggesting
talk to @anmonteiro at some point, I don't see why there isn't a small change here in om.next
well, perhaps we'll find future creative things to do that need these ideas. I'm going to stick wit hthe current impl
It really isn't a small change. The ability to plug-n-play your own database, networking, and everything else eliminates being able to do it well, I think
it's very clojury to support {:action ... :remote ... :untangled/action-result } sort of thing and there's no reason why env shouldn't be available, it's needed to merge&normalize, so why not for :untangled/action-result
ok, and you don't like on-success mutation? even though you have post-mutation and error mutation
jokingly just write a defmutation macro that looks like what you want but outputs 2 defmethods
but how often will you acutally need it? I've written a lot of Om code so far without needing it at all