DEV Community

Discussion on: rubico simplifies asynchronous code

Collapse
 
richytong profile image
Richard Tong

Here's a table from one of my archived posts that highlight some differences of rubico and rxjs

Features of RxJS Features of rubico
special asynchronous stream datatype, the Observable - wraps built-in types for reactive operations down the line no special data types: rubico works out of the box for built-in types; this includes async iterables
familiar design pattern: the Observer pattern - plugs into Observables no design pattern lock-in: rubico composes your functions together. You choose the design pattern
interop with Promises fully managed Promises: rubico stops you from having to manually resolve Promises, for example having to call
Promise.all on an array of Promises
functional programming style via Operators + Observable.prototype.pipe functional programming style by design
Roadblocks for RxJS More Features of rubico
async iterables undermine the need for rxjs's core datatype: the Observable. async iterables make rubico great; the async iterable is a core rubico (and JavaScript) datatype
multitude of concepts simple foundational concept: just pipe functions together
large API surface small, cohesive API surface
RxJS is hard to learn rubico is easy to learn

If you had sync and async functions that you wanted to compose together in a pipe, with rubico it would like something like

pipe([
  syncFnA,
  asyncFnA,
  syncFnB,
  asyncFnB,
])(someValue) // Promise { someOutput }

rubico pipe and other functions that accept functions all handle promise resolution for you. Conversely,

pipe([
  syncFnA,
  syncFnB,
])(someValue) // someOutput

If no functions are asynchronous, you'll get a synchronous value not wrapped in a Promise