Fork me on GitHub

I’ve been playing with over the weekend. Still trying to grasp all the ideas, but I think I get the main points simple_smile. 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 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 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?


or will the field get the dirty bit cleared when the request comes back


@iwankaramazow: Thats actually quite nice! Where did you stole it from? Would love to see the rest of the code simple_smile


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)?