D
D
Delakey Blackhole2017-04-02 15:57:45
JavaScript
Delakey Blackhole, 2017-04-02 15:57:45

Angular 2 longpolling how to send next request immediately after response?

this.pollTasks = Observable.interval(15000) 
        .switchMap(() => this.http.get(this.apiurl + 'longpoll'+ '/' + this.lastmessage))
        .map(res => {res.json();console.log(res);});

    this.pollTasks.subscribe(res => {
        this.Message(res);
        
    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Vasilkov, 2017-04-02
@gzhegow

I may be wrong, but the http.get() module node can do callbacks, if it is a native module, you need to put the second request into it. in your case, a request occurs, and the connection object ... maps?
If you draw a line with PHP, then you are trying to map a connection resource (you can call it a stream, if you want) - but the resource only contains data in the parameter, but in addition to the data box, it is also an object that fires events.
I would dance from this in an attempt to understand
if I understand everything correctly, then the connection object will fire events when it works or returns an error, and also receives the response text. you don’t need to map it yourself ...
But it may well be that I’m trying to tell the Eiffel Tower from my baseboard and wildly apologize in advance

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question