Return inner observable with wich operator?
up vote
0
down vote
favorite
chat.service.ts:
getUserChats(): Observable<Chat> {
return this.auth.currUser
.pipe(
take(1),
flatMap(user => this.afs
.collection('chats', ref => {
console.log(user.uid)
return ref.where('members', 'array-contains', `/users/${user.uid}`);
})
.snapshotChanges()
.pipe(
map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Chat;
const id = action.payload.doc.id;
return {id, ...data};
});
})
) as Observable<Chat>)
);
}
Is there a way to return the inner Observable which holds the chats from the user?
this.afs
.collection('chats', ref => {
console.log(user.uid)
return ref.where('members', 'array-contains', `/users/${user.uid}`);
})
.snapshotChanges()
.pipe(
map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Chat;
const id = action.payload.doc.id;
return {id, ...data};
});
})
) as Observable<Chat>
In the inner observable I need to wait for the user.uid to query for the chats.
typescript firebase rxjs google-cloud-firestore observable
add a comment |
up vote
0
down vote
favorite
chat.service.ts:
getUserChats(): Observable<Chat> {
return this.auth.currUser
.pipe(
take(1),
flatMap(user => this.afs
.collection('chats', ref => {
console.log(user.uid)
return ref.where('members', 'array-contains', `/users/${user.uid}`);
})
.snapshotChanges()
.pipe(
map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Chat;
const id = action.payload.doc.id;
return {id, ...data};
});
})
) as Observable<Chat>)
);
}
Is there a way to return the inner Observable which holds the chats from the user?
this.afs
.collection('chats', ref => {
console.log(user.uid)
return ref.where('members', 'array-contains', `/users/${user.uid}`);
})
.snapshotChanges()
.pipe(
map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Chat;
const id = action.payload.doc.id;
return {id, ...data};
});
})
) as Observable<Chat>
In the inner observable I need to wait for the user.uid to query for the chats.
typescript firebase rxjs google-cloud-firestore observable
What is the inner Observable?
– martin
Nov 7 at 13:38
@martin The firestore query: this.afs.collection('chats' .....
– filip
Nov 7 at 13:39
Just useconcatMap
instead offlatMap
– martin
Nov 7 at 13:40
Still doesn't work well @martin
– filip
Nov 7 at 13:43
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
chat.service.ts:
getUserChats(): Observable<Chat> {
return this.auth.currUser
.pipe(
take(1),
flatMap(user => this.afs
.collection('chats', ref => {
console.log(user.uid)
return ref.where('members', 'array-contains', `/users/${user.uid}`);
})
.snapshotChanges()
.pipe(
map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Chat;
const id = action.payload.doc.id;
return {id, ...data};
});
})
) as Observable<Chat>)
);
}
Is there a way to return the inner Observable which holds the chats from the user?
this.afs
.collection('chats', ref => {
console.log(user.uid)
return ref.where('members', 'array-contains', `/users/${user.uid}`);
})
.snapshotChanges()
.pipe(
map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Chat;
const id = action.payload.doc.id;
return {id, ...data};
});
})
) as Observable<Chat>
In the inner observable I need to wait for the user.uid to query for the chats.
typescript firebase rxjs google-cloud-firestore observable
chat.service.ts:
getUserChats(): Observable<Chat> {
return this.auth.currUser
.pipe(
take(1),
flatMap(user => this.afs
.collection('chats', ref => {
console.log(user.uid)
return ref.where('members', 'array-contains', `/users/${user.uid}`);
})
.snapshotChanges()
.pipe(
map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Chat;
const id = action.payload.doc.id;
return {id, ...data};
});
})
) as Observable<Chat>)
);
}
Is there a way to return the inner Observable which holds the chats from the user?
this.afs
.collection('chats', ref => {
console.log(user.uid)
return ref.where('members', 'array-contains', `/users/${user.uid}`);
})
.snapshotChanges()
.pipe(
map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Chat;
const id = action.payload.doc.id;
return {id, ...data};
});
})
) as Observable<Chat>
In the inner observable I need to wait for the user.uid to query for the chats.
typescript firebase rxjs google-cloud-firestore observable
typescript firebase rxjs google-cloud-firestore observable
asked Nov 7 at 13:23
filip
139110
139110
What is the inner Observable?
– martin
Nov 7 at 13:38
@martin The firestore query: this.afs.collection('chats' .....
– filip
Nov 7 at 13:39
Just useconcatMap
instead offlatMap
– martin
Nov 7 at 13:40
Still doesn't work well @martin
– filip
Nov 7 at 13:43
add a comment |
What is the inner Observable?
– martin
Nov 7 at 13:38
@martin The firestore query: this.afs.collection('chats' .....
– filip
Nov 7 at 13:39
Just useconcatMap
instead offlatMap
– martin
Nov 7 at 13:40
Still doesn't work well @martin
– filip
Nov 7 at 13:43
What is the inner Observable?
– martin
Nov 7 at 13:38
What is the inner Observable?
– martin
Nov 7 at 13:38
@martin The firestore query: this.afs.collection('chats' .....
– filip
Nov 7 at 13:39
@martin The firestore query: this.afs.collection('chats' .....
– filip
Nov 7 at 13:39
Just use
concatMap
instead of flatMap
– martin
Nov 7 at 13:40
Just use
concatMap
instead of flatMap
– martin
Nov 7 at 13:40
Still doesn't work well @martin
– filip
Nov 7 at 13:43
Still doesn't work well @martin
– filip
Nov 7 at 13:43
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Switchmap is okay, works well with it the problem was that 'array-contains' doesnt work for DocumentReferences in Firestore
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Switchmap is okay, works well with it the problem was that 'array-contains' doesnt work for DocumentReferences in Firestore
add a comment |
up vote
0
down vote
accepted
Switchmap is okay, works well with it the problem was that 'array-contains' doesnt work for DocumentReferences in Firestore
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Switchmap is okay, works well with it the problem was that 'array-contains' doesnt work for DocumentReferences in Firestore
Switchmap is okay, works well with it the problem was that 'array-contains' doesnt work for DocumentReferences in Firestore
answered Nov 8 at 9:39
filip
139110
139110
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%2f53190345%2freturn-inner-observable-with-wich-operator%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
What is the inner Observable?
– martin
Nov 7 at 13:38
@martin The firestore query: this.afs.collection('chats' .....
– filip
Nov 7 at 13:39
Just use
concatMap
instead offlatMap
– martin
Nov 7 at 13:40
Still doesn't work well @martin
– filip
Nov 7 at 13:43