Discussion: Allow effects to return an Observable
pvamshi opened this issue ยท comments
Disclaimer: Coming from Angular world ๐!
In libraries like NgRx, NgXs effects we always return an observable.
I feel this code snippet
store
.on('today')
.pipe(
debounce(100)
)
.subscribe(async date => {
let users = await api.get({ since: date })
store.set('users')(users)
})
can be
store
.on('today')
.pipe(
debounce(100),
mergeMap( date => {
return api.get({since: date})
}),
map( users => ({users})
)
I did not put much thought into the syntax. I will try to test this and give you the results. For now, sharing this idea here.