Questions tagged [subscribe]
994 questions
319
votes
10 answers
Subscribe is deprecated: Use an observer instead of an error callback
When I run the linter it says:
subscribe is deprecated: Use an observer instead of an error callback
Code from this angular app:
this.userService.updateUser(data).pipe(
tap(() => {bla bla bla})
).subscribe(
…

ismaestro
- 7,561
- 8
- 37
- 50
95
votes
4 answers
Angular 2 - Checking for server errors from subscribe
I feel like this scenario should be in the Angular 2 docs, but I can't find it anywhere.
Here's the scenario
submit a form (create object) that is invalid on the server
server returns a 400 bad request with errors I display on the form
after the…

Stephanie
- 1,039
- 1
- 7
- 12
57
votes
4 answers
tap() vs subscribe() to set a class property
I am very new to rxjs and was just wondering is it ok to setup a class property by piping the stream and tapping it, or it should i do it in the subscribe. To me either way works, just wonder if it is ok to do it as I see fit to my eyes or there is…

bulforce
- 991
- 1
- 6
- 11
56
votes
5 answers
Should I unsubscribe from events?
I have 3 questions concerning events:
Should I always unsubscribe events that were subscribed?
What happens if I do NOT?
In the below examples, how would you unsubscribe from the subscribed events?
I have for example this code:
Ctor: Purpose: For…

Elisabeth
- 20,496
- 52
- 200
- 321
45
votes
5 answers
Angular 2: How to call a function after get a response from subscribe http.post
I need to call a method after get the data from the http post request
service: request.service.TS
get_categories(number){
this.http.post( url, body, {headers: headers, withCredentials:true})
.subscribe(
response => {
this.total…

Louise
- 563
- 1
- 5
- 10
44
votes
4 answers
RxJS Observables nested subscriptions?
What's the way to simplify something like the following code example?
I can't find the right operator.. could anyone give a short example?
this.returnsObservable1(...)
.subscribe(
success => {
this.returnsObservable2(...)
…

Max Solid
- 1,213
- 3
- 21
- 32
31
votes
2 answers
Observables : Cancel previous http request on new subscription call
I am working on a search functionality for my project. Once the user types anything on the search bar; on any change in search text I'll be sending the text to backend for validation and receive a response (error or no error in…

D_S_X
- 1,351
- 5
- 17
- 35
30
votes
4 answers
Angular 2 observable subscribing twice executes call twice
Problem
I subscribe to an httpClient.get observable twice. However, this means that my call gets executed twice. Why is this?
Proof
For every subscribe() I do, I get another line in the login page.
Code (onSubmit() from login page button)
var…

Rico
- 604
- 1
- 9
- 16
24
votes
2 answers
q.all for angular2 observables
is there something like q.all to resolve all http api requests in angular2?
In angular1, I can do something like this:
var promises = [api.getA(),api.getB()];
$q.all(promises).then(function(response){
// response[0] --> A
// response[1] …

kdu
- 1,259
- 4
- 12
- 18
19
votes
0 answers
Webcal / .ics subscribe to feed from within Android App
For a recent application, I want to provide the ability to subscribe to a calendar feed while staying on the android device. Going to calendar.google.com and manually adding the http link (ics) isn't an option. I can't really find a lot of…

Jordy
- 1,764
- 1
- 22
- 32
18
votes
1 answer
Is it safe to unsubscribe from an event that has never been subscribed?
For example, if these codes:
Button button1 = new Button();
// ...
button1.Click -= button1_Clicked;
are executed before:
button1.Click += button1_Clicked;
I found no error or exception, but I am wondering if there…

Setyo N
- 1,953
- 2
- 26
- 28
18
votes
2 answers
Mailchimp subscribe using jQuery AJAX?
What is a complete jQuery solution to subscribing uses to a list on Mailchimp?
The problem is that most solutions either use a library or require server side code. I want a quick elegant solution, which gives me complete control over the UI, hence…

Nagra
- 1,529
- 3
- 15
- 25
15
votes
1 answer
combineLatest with FormControl valueChanges event binding not emitting
I listen to 2 forms via 2 [formControl] "toppings":array and "toppings2":array.
I must have the 2 values of the forms in the same time. So i combine my two observables with "CombineLatest"
My code:
ngOnInit()…

Newbiiiie
- 1,401
- 3
- 14
- 33
14
votes
1 answer
Javascript Websocket Subscribe to Channel
I am trying to subscribe to channel using native WebSocket in vanilla javascript (without using any library) [as I have just read it's possible but I am not sure - please correct me if I'm wrong].
I am trying to get the latest price of bitcoin
let…

senty
- 12,385
- 28
- 130
- 260
13
votes
3 answers
How to programmatically subscribe a user to a google calendar using javascript?
Hey i'm able to authenticate and authorize a user with the javascript API for google calendar. what i want to do next is subscribe that user to a public calendar. I was thinking i could just call the google.gdata.calendar.CalendarEntry constructor…

Devin Crossman
- 7,454
- 11
- 64
- 102