Webworkers for jobs to execute in the background

I have a method in javascript which roughly takes 5 seconds to return when the first signup is done. But I am displaying the show page to the user as soon his account gets created on the rails server. I am creating his account on the rails server as well as on the xmpp server. But if the user does something within those 5 seconds on the client which should be done only after the 5 seconds are over, I get an error. I want the user to be able to do anything he wants while these javascript jobs happening on the background because I am also replicating these actions on the rails side.

For example, creating a group should happen only after those 5 seconds. But this should not matter to the user since I am storing the group on the rails side too. But at the same time I do want the same action be performed on the javascript side which is actually connecting to a different server which is XMPP.

When the front end exposes the group you could have various operations on it disabled until the AJAX request returns successfully. As part of the AJAX call’s success handler you can “unlock” the features.

Or you could simply add error handling that says the group isn’t available to handle the request just yet, try again in a moment. Lots of options; Lots of them complicated. You need to decide what you want the user experience to be and then do it.

Let me give one more example, Say the user logs in to the rails app. then immediately the the user show page is shown. Now the javascript work of logging on to xmpp server starts which takes 5 secs. While this is happening, the user goes and creates a group which is created on the rails app and immediately shows up on the home page page via the remote :true option. Now the group has to be created on the xmpp server also using javascript which can happen only after the user has logged onto the xmpp server. But while this is happening, the user might click on the group and do actions on the group like creating the timetable which actually has no xmpp counterpart.
So the actions taken by the user are captured by the browser and done one by one after each other. And at the same time giving the user on the browser no delays.

I am doing this actually because I want XMPP communication when these users are communicating from their mobiles. Maybe later introduce social gaming, one to many messaging on their mobiles. etc.


Since you and I have talked about this product on a mentoring call, I know that it’s an MVP for an idea you have.

I’d like to encourage you to make it much, MUCH simpler.

This, and many of your other posts, are asking about advanced topics like scalability and substantial asynchronous behavior.

These topics are worth considering when you have a few hundred users. Since you currently have zero, you should be struggling to make the simplest possible product and get it launched. If a feature is very difficult to do, you should cut it unless it’s absolutely essential.

I’ve seen this before. You are running the substantial risk of spending lots of time developing a complicated product that either never launches or launches and generates almost no actual interest.

I think I do this because I love the part of developing and solving problems. But you are right. I will try to launch it fast and take it to at least one college or student community as soon as possible.

Just a fear that someone might come and say they don’t like it so I guess I was trying to avoid that.