this.pickupStatus.emit is not a function
up vote
3
down vote
favorite
I have a provider that listens to changes to my firestore database and changes the status of a driver pickup request status.
here is my pickuprequest function in my driver's provider
getDriverPickupRequest(id)
{
this.DriverCollection.doc<Driver>(id).valueChanges()
.subscribe(data => {
this.pickuprequest.changePickupStatus(data.pickupRequest);
}
Now i have a service that watches the change and emits it to my home page.
private pickupRequest = new BehaviorSubject<boolean>(false);
public pickupStatus = this.pickupRequest.asObservable();
changePickupStatus(value: boolean) {
this.pickupStatus.emit(value);
}
constructor(public http: HttpClient) {
//console.log('Hello PickuprequestProvider Provider');
}
Now i get an error that says 'this.pickupStatus.emit is not a function'. What is wrong with the code?
angular typescript ionic3
add a comment |
up vote
3
down vote
favorite
I have a provider that listens to changes to my firestore database and changes the status of a driver pickup request status.
here is my pickuprequest function in my driver's provider
getDriverPickupRequest(id)
{
this.DriverCollection.doc<Driver>(id).valueChanges()
.subscribe(data => {
this.pickuprequest.changePickupStatus(data.pickupRequest);
}
Now i have a service that watches the change and emits it to my home page.
private pickupRequest = new BehaviorSubject<boolean>(false);
public pickupStatus = this.pickupRequest.asObservable();
changePickupStatus(value: boolean) {
this.pickupStatus.emit(value);
}
constructor(public http: HttpClient) {
//console.log('Hello PickuprequestProvider Provider');
}
Now i get an error that says 'this.pickupStatus.emit is not a function'. What is wrong with the code?
angular typescript ionic3
@PankajParkar .next also gives the same error
– Patrick Obafemi
Nov 10 at 18:00
Replacethis.pickupStatus.emit(value);
bythis. pickupRequest.next(value);
– Sunil Singh
Nov 10 at 18:13
@PatrickObafemi my bad. check my answer with detailed explanation.
– Pankaj Parkar
Nov 10 at 18:17
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a provider that listens to changes to my firestore database and changes the status of a driver pickup request status.
here is my pickuprequest function in my driver's provider
getDriverPickupRequest(id)
{
this.DriverCollection.doc<Driver>(id).valueChanges()
.subscribe(data => {
this.pickuprequest.changePickupStatus(data.pickupRequest);
}
Now i have a service that watches the change and emits it to my home page.
private pickupRequest = new BehaviorSubject<boolean>(false);
public pickupStatus = this.pickupRequest.asObservable();
changePickupStatus(value: boolean) {
this.pickupStatus.emit(value);
}
constructor(public http: HttpClient) {
//console.log('Hello PickuprequestProvider Provider');
}
Now i get an error that says 'this.pickupStatus.emit is not a function'. What is wrong with the code?
angular typescript ionic3
I have a provider that listens to changes to my firestore database and changes the status of a driver pickup request status.
here is my pickuprequest function in my driver's provider
getDriverPickupRequest(id)
{
this.DriverCollection.doc<Driver>(id).valueChanges()
.subscribe(data => {
this.pickuprequest.changePickupStatus(data.pickupRequest);
}
Now i have a service that watches the change and emits it to my home page.
private pickupRequest = new BehaviorSubject<boolean>(false);
public pickupStatus = this.pickupRequest.asObservable();
changePickupStatus(value: boolean) {
this.pickupStatus.emit(value);
}
constructor(public http: HttpClient) {
//console.log('Hello PickuprequestProvider Provider');
}
Now i get an error that says 'this.pickupStatus.emit is not a function'. What is wrong with the code?
angular typescript ionic3
angular typescript ionic3
asked Nov 10 at 17:52
Patrick Obafemi
112113
112113
@PankajParkar .next also gives the same error
– Patrick Obafemi
Nov 10 at 18:00
Replacethis.pickupStatus.emit(value);
bythis. pickupRequest.next(value);
– Sunil Singh
Nov 10 at 18:13
@PatrickObafemi my bad. check my answer with detailed explanation.
– Pankaj Parkar
Nov 10 at 18:17
add a comment |
@PankajParkar .next also gives the same error
– Patrick Obafemi
Nov 10 at 18:00
Replacethis.pickupStatus.emit(value);
bythis. pickupRequest.next(value);
– Sunil Singh
Nov 10 at 18:13
@PatrickObafemi my bad. check my answer with detailed explanation.
– Pankaj Parkar
Nov 10 at 18:17
@PankajParkar .next also gives the same error
– Patrick Obafemi
Nov 10 at 18:00
@PankajParkar .next also gives the same error
– Patrick Obafemi
Nov 10 at 18:00
Replace
this.pickupStatus.emit(value);
by this. pickupRequest.next(value);
– Sunil Singh
Nov 10 at 18:13
Replace
this.pickupStatus.emit(value);
by this. pickupRequest.next(value);
– Sunil Singh
Nov 10 at 18:13
@PatrickObafemi my bad. check my answer with detailed explanation.
– Pankaj Parkar
Nov 10 at 18:17
@PatrickObafemi my bad. check my answer with detailed explanation.
– Pankaj Parkar
Nov 10 at 18:17
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
A BehaviorSubject
has a next
method on it that is used to push new values to the observable.
Problem: You're calling emit
on pickupStatus
which is an Observable
when you should have called next
on pickupRequest
which is a BehaviorSubject
Fix:
private pickupRequest = new BehaviorSubject<boolean>(false);
public pickupStatus = this.pickupRequest.asObservable();
changePickupStatus(value: boolean) {
this.pickupRequest.next(value);
}
Use this.pickupRequest.next(value);
where we are essentially pushing a new value on the pickupRequest
which is a BehaviorSubject
by using the next
method on it.
add a comment |
up vote
1
down vote
.emit()
only works on EventEmitter
, using .next()
on pickup status won't work as Observable
is read-only.
hello. next() also gives the same error.
– Patrick Obafemi
Nov 10 at 17:59
.next() only works on Subject or any class that extends Subject. Convert pickupStatus to eventEmitter and use emit() and it will work.
– Andrei Dumitrescu-Tudor
Nov 10 at 18:02
@AndreiDumitrescu-Tudor .next will work for both Subject and Behavior subject. Every observable in RxJs .next is the default method to emit the value
– NinjaJami
Nov 10 at 18:26
@NinjaJami as per reactivex.io/rxjs/class/es6/Observable.js~Observable.html observable is read only. Subject is the one that can emit values via next().
– Andrei Dumitrescu-Tudor
Nov 10 at 18:36
@AndreiDumitrescu-Tudor here is an example stackblitz.com/edit/…
– NinjaJami
Nov 10 at 18:38
|
show 2 more comments
up vote
1
down vote
emit
method exist on EventEmitter
object not on BehaviourSubject
. Over here you are exposing the stream using this.pickupRequest.asObservable()
method. I believe this is safest way to expose a stream so that the consumer of this stream will not push any data into a stream. Basically to prevent leaky abstraction. If consumer tries to do pickupStatus.next(data)
on that it will result to an error. This is expected behavior. This way we give readonly
access to consumer of a stream.
In order to send data over a stream you have to call .next
method on BehaviorSubject
instance, it auto magically let subscribers knows that new data has pushed into a stream.
pickupRequest.next(data)
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
A BehaviorSubject
has a next
method on it that is used to push new values to the observable.
Problem: You're calling emit
on pickupStatus
which is an Observable
when you should have called next
on pickupRequest
which is a BehaviorSubject
Fix:
private pickupRequest = new BehaviorSubject<boolean>(false);
public pickupStatus = this.pickupRequest.asObservable();
changePickupStatus(value: boolean) {
this.pickupRequest.next(value);
}
Use this.pickupRequest.next(value);
where we are essentially pushing a new value on the pickupRequest
which is a BehaviorSubject
by using the next
method on it.
add a comment |
up vote
1
down vote
accepted
A BehaviorSubject
has a next
method on it that is used to push new values to the observable.
Problem: You're calling emit
on pickupStatus
which is an Observable
when you should have called next
on pickupRequest
which is a BehaviorSubject
Fix:
private pickupRequest = new BehaviorSubject<boolean>(false);
public pickupStatus = this.pickupRequest.asObservable();
changePickupStatus(value: boolean) {
this.pickupRequest.next(value);
}
Use this.pickupRequest.next(value);
where we are essentially pushing a new value on the pickupRequest
which is a BehaviorSubject
by using the next
method on it.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
A BehaviorSubject
has a next
method on it that is used to push new values to the observable.
Problem: You're calling emit
on pickupStatus
which is an Observable
when you should have called next
on pickupRequest
which is a BehaviorSubject
Fix:
private pickupRequest = new BehaviorSubject<boolean>(false);
public pickupStatus = this.pickupRequest.asObservable();
changePickupStatus(value: boolean) {
this.pickupRequest.next(value);
}
Use this.pickupRequest.next(value);
where we are essentially pushing a new value on the pickupRequest
which is a BehaviorSubject
by using the next
method on it.
A BehaviorSubject
has a next
method on it that is used to push new values to the observable.
Problem: You're calling emit
on pickupStatus
which is an Observable
when you should have called next
on pickupRequest
which is a BehaviorSubject
Fix:
private pickupRequest = new BehaviorSubject<boolean>(false);
public pickupStatus = this.pickupRequest.asObservable();
changePickupStatus(value: boolean) {
this.pickupRequest.next(value);
}
Use this.pickupRequest.next(value);
where we are essentially pushing a new value on the pickupRequest
which is a BehaviorSubject
by using the next
method on it.
edited Nov 10 at 18:13
answered Nov 10 at 18:07
SiddAjmera
9,40921037
9,40921037
add a comment |
add a comment |
up vote
1
down vote
.emit()
only works on EventEmitter
, using .next()
on pickup status won't work as Observable
is read-only.
hello. next() also gives the same error.
– Patrick Obafemi
Nov 10 at 17:59
.next() only works on Subject or any class that extends Subject. Convert pickupStatus to eventEmitter and use emit() and it will work.
– Andrei Dumitrescu-Tudor
Nov 10 at 18:02
@AndreiDumitrescu-Tudor .next will work for both Subject and Behavior subject. Every observable in RxJs .next is the default method to emit the value
– NinjaJami
Nov 10 at 18:26
@NinjaJami as per reactivex.io/rxjs/class/es6/Observable.js~Observable.html observable is read only. Subject is the one that can emit values via next().
– Andrei Dumitrescu-Tudor
Nov 10 at 18:36
@AndreiDumitrescu-Tudor here is an example stackblitz.com/edit/…
– NinjaJami
Nov 10 at 18:38
|
show 2 more comments
up vote
1
down vote
.emit()
only works on EventEmitter
, using .next()
on pickup status won't work as Observable
is read-only.
hello. next() also gives the same error.
– Patrick Obafemi
Nov 10 at 17:59
.next() only works on Subject or any class that extends Subject. Convert pickupStatus to eventEmitter and use emit() and it will work.
– Andrei Dumitrescu-Tudor
Nov 10 at 18:02
@AndreiDumitrescu-Tudor .next will work for both Subject and Behavior subject. Every observable in RxJs .next is the default method to emit the value
– NinjaJami
Nov 10 at 18:26
@NinjaJami as per reactivex.io/rxjs/class/es6/Observable.js~Observable.html observable is read only. Subject is the one that can emit values via next().
– Andrei Dumitrescu-Tudor
Nov 10 at 18:36
@AndreiDumitrescu-Tudor here is an example stackblitz.com/edit/…
– NinjaJami
Nov 10 at 18:38
|
show 2 more comments
up vote
1
down vote
up vote
1
down vote
.emit()
only works on EventEmitter
, using .next()
on pickup status won't work as Observable
is read-only.
.emit()
only works on EventEmitter
, using .next()
on pickup status won't work as Observable
is read-only.
answered Nov 10 at 17:58
Andrei Dumitrescu-Tudor
875
875
hello. next() also gives the same error.
– Patrick Obafemi
Nov 10 at 17:59
.next() only works on Subject or any class that extends Subject. Convert pickupStatus to eventEmitter and use emit() and it will work.
– Andrei Dumitrescu-Tudor
Nov 10 at 18:02
@AndreiDumitrescu-Tudor .next will work for both Subject and Behavior subject. Every observable in RxJs .next is the default method to emit the value
– NinjaJami
Nov 10 at 18:26
@NinjaJami as per reactivex.io/rxjs/class/es6/Observable.js~Observable.html observable is read only. Subject is the one that can emit values via next().
– Andrei Dumitrescu-Tudor
Nov 10 at 18:36
@AndreiDumitrescu-Tudor here is an example stackblitz.com/edit/…
– NinjaJami
Nov 10 at 18:38
|
show 2 more comments
hello. next() also gives the same error.
– Patrick Obafemi
Nov 10 at 17:59
.next() only works on Subject or any class that extends Subject. Convert pickupStatus to eventEmitter and use emit() and it will work.
– Andrei Dumitrescu-Tudor
Nov 10 at 18:02
@AndreiDumitrescu-Tudor .next will work for both Subject and Behavior subject. Every observable in RxJs .next is the default method to emit the value
– NinjaJami
Nov 10 at 18:26
@NinjaJami as per reactivex.io/rxjs/class/es6/Observable.js~Observable.html observable is read only. Subject is the one that can emit values via next().
– Andrei Dumitrescu-Tudor
Nov 10 at 18:36
@AndreiDumitrescu-Tudor here is an example stackblitz.com/edit/…
– NinjaJami
Nov 10 at 18:38
hello. next() also gives the same error.
– Patrick Obafemi
Nov 10 at 17:59
hello. next() also gives the same error.
– Patrick Obafemi
Nov 10 at 17:59
.next() only works on Subject or any class that extends Subject. Convert pickupStatus to eventEmitter and use emit() and it will work.
– Andrei Dumitrescu-Tudor
Nov 10 at 18:02
.next() only works on Subject or any class that extends Subject. Convert pickupStatus to eventEmitter and use emit() and it will work.
– Andrei Dumitrescu-Tudor
Nov 10 at 18:02
@AndreiDumitrescu-Tudor .next will work for both Subject and Behavior subject. Every observable in RxJs .next is the default method to emit the value
– NinjaJami
Nov 10 at 18:26
@AndreiDumitrescu-Tudor .next will work for both Subject and Behavior subject. Every observable in RxJs .next is the default method to emit the value
– NinjaJami
Nov 10 at 18:26
@NinjaJami as per reactivex.io/rxjs/class/es6/Observable.js~Observable.html observable is read only. Subject is the one that can emit values via next().
– Andrei Dumitrescu-Tudor
Nov 10 at 18:36
@NinjaJami as per reactivex.io/rxjs/class/es6/Observable.js~Observable.html observable is read only. Subject is the one that can emit values via next().
– Andrei Dumitrescu-Tudor
Nov 10 at 18:36
@AndreiDumitrescu-Tudor here is an example stackblitz.com/edit/…
– NinjaJami
Nov 10 at 18:38
@AndreiDumitrescu-Tudor here is an example stackblitz.com/edit/…
– NinjaJami
Nov 10 at 18:38
|
show 2 more comments
up vote
1
down vote
emit
method exist on EventEmitter
object not on BehaviourSubject
. Over here you are exposing the stream using this.pickupRequest.asObservable()
method. I believe this is safest way to expose a stream so that the consumer of this stream will not push any data into a stream. Basically to prevent leaky abstraction. If consumer tries to do pickupStatus.next(data)
on that it will result to an error. This is expected behavior. This way we give readonly
access to consumer of a stream.
In order to send data over a stream you have to call .next
method on BehaviorSubject
instance, it auto magically let subscribers knows that new data has pushed into a stream.
pickupRequest.next(data)
add a comment |
up vote
1
down vote
emit
method exist on EventEmitter
object not on BehaviourSubject
. Over here you are exposing the stream using this.pickupRequest.asObservable()
method. I believe this is safest way to expose a stream so that the consumer of this stream will not push any data into a stream. Basically to prevent leaky abstraction. If consumer tries to do pickupStatus.next(data)
on that it will result to an error. This is expected behavior. This way we give readonly
access to consumer of a stream.
In order to send data over a stream you have to call .next
method on BehaviorSubject
instance, it auto magically let subscribers knows that new data has pushed into a stream.
pickupRequest.next(data)
add a comment |
up vote
1
down vote
up vote
1
down vote
emit
method exist on EventEmitter
object not on BehaviourSubject
. Over here you are exposing the stream using this.pickupRequest.asObservable()
method. I believe this is safest way to expose a stream so that the consumer of this stream will not push any data into a stream. Basically to prevent leaky abstraction. If consumer tries to do pickupStatus.next(data)
on that it will result to an error. This is expected behavior. This way we give readonly
access to consumer of a stream.
In order to send data over a stream you have to call .next
method on BehaviorSubject
instance, it auto magically let subscribers knows that new data has pushed into a stream.
pickupRequest.next(data)
emit
method exist on EventEmitter
object not on BehaviourSubject
. Over here you are exposing the stream using this.pickupRequest.asObservable()
method. I believe this is safest way to expose a stream so that the consumer of this stream will not push any data into a stream. Basically to prevent leaky abstraction. If consumer tries to do pickupStatus.next(data)
on that it will result to an error. This is expected behavior. This way we give readonly
access to consumer of a stream.
In order to send data over a stream you have to call .next
method on BehaviorSubject
instance, it auto magically let subscribers knows that new data has pushed into a stream.
pickupRequest.next(data)
edited Nov 10 at 18:30
answered Nov 10 at 18:14
Pankaj Parkar
111k15157232
111k15157232
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241807%2fthis-pickupstatus-emit-is-not-a-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@PankajParkar .next also gives the same error
– Patrick Obafemi
Nov 10 at 18:00
Replace
this.pickupStatus.emit(value);
bythis. pickupRequest.next(value);
– Sunil Singh
Nov 10 at 18:13
@PatrickObafemi my bad. check my answer with detailed explanation.
– Pankaj Parkar
Nov 10 at 18:17