This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-06
Channels
- # aleph (79)
- # bangalore-clj (3)
- # beginners (49)
- # boot (74)
- # cider (10)
- # cljs-dev (21)
- # cljsrn (2)
- # clojure (105)
- # clojure-berlin (1)
- # clojure-brasil (1)
- # clojure-dusseldorf (1)
- # clojure-korea (1)
- # clojure-poland (3)
- # clojure-russia (38)
- # clojure-spec (146)
- # clojure-uk (20)
- # clojurescript (70)
- # cloverage (1)
- # component (1)
- # core-async (23)
- # css (16)
- # cursive (22)
- # datascript (1)
- # datomic (22)
- # defnpodcast (6)
- # emacs (60)
- # events (1)
- # hoplon (94)
- # jobs (1)
- # jobs-rus (13)
- # luminus (11)
- # off-topic (11)
- # om (48)
- # onyx (5)
- # proton (7)
- # re-frame (87)
- # reagent (39)
- # rethinkdb (1)
- # ring-swagger (14)
- # rum (6)
- # specter (14)
- # untangled (105)
- # vim (6)
- # yada (22)
if I have a mutation 'create-object
what's the pattern for transacting 'show-object
IFF 'create-object
succeeds in creating the object? should I have a post-mutation for 'create-object
and transact! 'show-object
in the post mutation?
'show-object
changes the :current-tab
to show the object, and does load-field-action
so, if the server denies something, you can throw an error that will trigger a fallback
so here's the thing. A single transaction in UI will be sent as single net transaction
so, yes, if you implement it on the server to abort at create-object, then show-object should not happen
I would, however, tend to use alternate logic. I would not be showing UI for making the object if it was possible for happy path to deny.
If there are are any more NYC area folks in here, I’d like to host a Clojure Meetup about Untangled. RSVP here! http://www.meetup.com/Clojure-NYC/events/234676309/
I see it's like {:http://datomic.id/foobar 32 }
then I guess that updates the table in app-state, from {:table { :http://datomic.id/foobar { ..}}} to {:table {42 { ...}}}
You should use
(om/tempid)` at the UI to send temp ids into your mutation ` I don't quite follow, so
(defmethod mutation 'my/mutation [e k p]
{:remote true
:action ???} )
https://github.com/untangled-web/untangled-todomvc/blob/master/src/client/untangled_todomvc/mutations.cljs#L13 there is no call to om/tempid
the local action is just to put the data in your db, as normal (including the tempid)
remember that mutations are called more than once on the client (once for UI, and once for each remote). Tempid returns something diff every time 🙂
The only way we differ from Om Next on this is that we handle the joining together of tempids from the server for you...which you normally have to do manually.
ok so in todomvc (update-in [:todos :list/items] (fn [todos] ((fnil conj []) todos [:todo/by-id id]))) (assoc-in [:todo/by-id id] {:db/id id :item/label text}))))}) the untangled engine automatically finds all references to this 'id' in tables, and links, etc
In regular Om, you have to say what your ID fields are called...it is an optimization so that migrate is a bit faster. In practice, it really isn't so slow (network delay will be much longer typically)...so we opted for ease instead of premature optimization. We can always work on speeding it up later if it becomes a problem.
For example, mark-n-sweep to remove missing data from responses is optimized by walking the query. We could do similar things for migrate that would speed it up. We really haven't found the need, though.
is this right?
(defmethod api-mutation 'booking2/create
[env key {:keys [id]}]
{:action (fn []
(println "id: " (pr-str id))
{:tempids {id 42}})})
is that client or server?
(defmethod m/mutation 'booking2/create [env _ {:keys [id]}]
{:remote true
:action (fn []
(m/swap-this! env assoc :new-booking-id [:booking/by-id id]))})
(nav-item {:title "create booking #2"
:onClick #(transact! T [(booking2/create {:id (om/tempid)})
(app/choose-tab {:tab :booking2})])})
is 42 what you are always returning?
im not seeing anything obvious thats wrong
(nav-item {:title "create booking #2"
:onClick #(transact! T [(booking2/create {:id (om/tempid)})
(app/choose-tab {:tab :booking2})])})
doesn't work(nav-item {:title "create booking #2"
:onClick #(transact! T [(booking2/create {:id (om/tempid)})})
doesthat looks like a bug
nuking? thats not a good idea
lol >.<
you can also switch tabs with merely a (om/merge Root {:current-tab (initial-state MyTabComponent nil)})
which is neat
well it sounds like that was the problem
shouldnt you be switching the tab ident to point to the new tab instead?
you could probably do a checkouts if you really want it