I have an app which allows users to submit a post to Twitter. It's using Ember.Data with a Django Rest Framework back end. A user posts a Message, which goes to the server, then submits to Twitter, then returns the response back to the client. That part all works fine but I want to build in code to manage the times when the request fails, either on our server or on the request to Twitter.
I've found documentation on an isError state for Models but I'm not sure if this is the correct property I'm looking for.
Here's the code I'm currently implementing:
saveMessage: function(text, postingWindow){
var acct = Social.Account.find(this.get("id")),
msg = Social.store.createRecord(
Social.Message,
{
text: text,
account: acct,
created: new Date()
}
);
acct.get("messages").addObject(msg);
Social.store.commit();
}
Basically what I'm trying to accomplish is to hold off displaying the message in the UI until I know I have success from the user. But on the flip side I don't want to wait forever if I can get an error state right away.