On Wednesday, April 19, 2017 at 3:25:03 AM UTC+2, rob...@leapyear.io wrote:
>
> Imagine you have an Angular 2 app that makes calls to a REST API with 
> Observables.  Further imagine that the response time of these calls will 
> take many tens of minutes or even hours to return a response.
>
> In many cases your users will launch such calls to the REST API at the end 
> of their work day, close their laptop, and go home.  When they login in the 
> morning, they will be looking to be notified about the status of the calls 
> they initiated the previous day.
>
> Might you have any suggestions on how best to architect such a scenario?
>
>
As Sander has suggested, this sounds like a server-side solution. You don't 
say what technology you use on backend, but take a look at what kue does: 
https://github.com/Automattic/kue (it's a node.js/redis based module). 

Basically your server:
1. receives a request 
2. queues the job and saves some job identifier
3. returns that identifier to the client.
4. kicks off the job in background - or even better, lets something else 
handle the job processing part entirely and update the job id status.

So now your Angular client has to make a request and it receives back the 
job id - immediately, not after an hour. It can then store this job id 
(say, in local storage) - so even if the user closes their laptop and goes 
home, tomorrow the job id will still be there. Then when the page is 
restored (or reloaded or whatever) you can ask the server if your job is 
complete.

Now that's just a rough outline, many details depend on what you actually 
do, what you use to do it and other things.

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to