This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-25
Channels
- # admin-announcements (5)
- # arachne (1)
- # beginners (29)
- # boot (36)
- # cider (110)
- # clara (1)
- # cljs-dev (3)
- # cljs-edn (14)
- # cljsrn (24)
- # clojure (63)
- # clojure-belgium (3)
- # clojure-dusseldorf (5)
- # clojure-greece (9)
- # clojure-russia (142)
- # clojure-sg (15)
- # clojure-uk (20)
- # clojurebridge (4)
- # clojurescript (58)
- # data-science (1)
- # datomic (37)
- # editors (2)
- # editors-rus (7)
- # emacs (1)
- # garden (31)
- # hoplon (3)
- # jobs-discuss (8)
- # keechma (86)
- # leiningen (1)
- # liberator (2)
- # mount (23)
- # off-topic (2)
- # om (18)
- # onyx (42)
- # planck (1)
- # quil (6)
- # re-frame (8)
- # reagent (3)
- # ring-swagger (1)
- # specter (4)
- # untangled (1)
I’ve been playing with om.next over the weekend. Still trying to grasp all the ideas, but I think I get the main points . However, I cannot find anything about loading-states. When I delegate a mutation or read to a remote, how do I know if its loaded (or errored)? I’d like to show a loading-indicator in the UI when appropriate.
is getInitialState
not supported in om next? I defined it but it's never called, and my component state is initially empty
@devth: use initLocalState
@anmonteiro: perfect, thanks!
@stex: Check out https://github.com/omcljs/om/wiki/Om-Next-FAQ#how-can-i-implement-optimistic-commits. I think what you want to do is "optimistically" set a special flag in the local state that says an item is still loading, which will then be removed when the server response is merged in
@stex: take a look at the #C0PULSD25 framework built on top of Om Next, if you need inspiration.
or you could try to implement the following: (basically what untangled does)
-implement a new mutation which places a loading marker at the appropriate place in your state, before sending the mutation of to the remote
-make sure you also place the onSuccess
or onFailure
in your app state. (you could combine that with the previous step)
-when a remote comes back with the response, get the onSuccess
or onFailure
handlers out of your state and run those
(you need to have the reconciler available in your send function..)
@drcode. Thanks, didn’t think about that! I’m not sure what I actually like it, since it feels quite low level. Maybe I need to play with it a bit.
@iwankaramazow: Thanks! I did have a quick look at the untangled client framework, and I’m not 100% sure how it works yet. Do you have experience with this in production apps? I’m currently working in an app which wraps all remote calls in go-blocks, which enables you to fire requests all at once, or one after another. Doing this with callbacks would result in a mini callback hell.
But haven’t enough om.next experience yet. A single remote-call is probably enough for most use-cases.
@stex: define 'production' 😛 I have a small app in 'production' which manages lectures for a chiropractor, more of a glorified todo-list app with routing. I store a bunch of mutation-queries in my app state, whenever a response arrive, I transact those mutations given the new state (w/ response merged back in)
Ofcourse I remove those mutations whenever they're transacted
This is pretty basic, but it works
Example: [(auth/login {:mail ~mail :password ~password}) (post-mutate {:query [(redirect-to-dashboard!})]
, the post-mutate part gets run once the response arrives
stole that shamelessly from untangled 😇
@iwankaramazow: if a user is typing in a field, starts a server sync, then keeps typing while it is happening, will this be handled correctly with your strategy?
@iwankaramazow: Thats actually quite nice! Where did you stole it from? Would love to see the rest of the code
Question: Nothing I’ve seen suggests otherwise, but is it correct to assume an Om component can be rendered within a React.js component (in a pure JS project)?