How to do a conditional return in withObservables with a non-reactive value? #1427
-
So, I have a user model, and have an Here is how I do it. Since I need to handle the case which the How to solve this problem? Or I would say what is the const enhance = compose<any, any>(
// step A
withObservables([], ({ database }: { database: Database }) => ({
currentUser: database.collections
.get(Tables.Users)
.query(Q.where("id", CurrentUser.userId()))
.observe(),
})),
// step B
withObservables(
["currentUser"],
({ currentUser }: { currentUser: User[] }) => ({
assignedToMeCount: isEmpty(currentUser)
? 0
: currentUser[0].assignedTasks().observeCount(),
})
)
); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Simply return |
Beta Was this translation helpful? Give feedback.
Simply return
foo ? Rx.of(0) : query.observeCount()
https://rxjs-dev.firebaseapp.com/api/index/function/of