-
Notifications
You must be signed in to change notification settings - Fork 0
Promises instead of RXJS
Olli Raitio edited this page Mar 15, 2024
·
2 revisions
laji-api uses plain Promises with async/await instead of RXJS in the controllers and services. RXJS doesn't bring much to the table since the data flow isn't reactive, while code written with async/await tends to be more flat and less bloated in syntax. Since Nest is coupled with RXJS, we must use it in someplaces, like interceptors, filters and pipes. In these cases we usually convert the RXJS Observable into a Promise as soon as possible, so we can handle it with our Promise-based own toolset.
RXJS pipes offer a nice syntax for splitting code into smaller operations with clean purpose. For writing similar syntax, there are pipe() and promisePipe() util methods which allow similar syntax as RXJS' pipes.