nats-io / nats.ts

TypeScript Node.js client for NATS, the cloud native messaging system
https://www.nats.io
Apache License 2.0
178 stars 13 forks source link

Clarify that this project is meant to supersede nats.js #63

Closed gnarea closed 4 years ago

gnarea commented 4 years ago

Hello,

I was confused by the relationship between this project and nats.js, and it took be a fair bit of browsing around to find that this project is meant to supersede nats.js eventually (see #15).

I think it'd be good if this plan were made explicit in the documentation for both projects.

aricart commented 4 years ago

@gnarea nats.js is a traditional node event-driven library - you register event handlers for messages. nats.js is the second oldest nats library (originally released in 12/2011). The library API has changed very little since then. Because it was an early node project, it also has callback patterns that are non-standard. Many of the API calls have optional arguments in the middle, which is now considered a bad practice.

nats.ts is a more modern library, the APIs are simpler, and where possible it uses promises instead of requiring a callback. This has the benefits of allowing await, which greatly simplifies some of the logic and structure of the client code.

I am not so sure that nats.ts will supersede nats.js, anytime soon as different developers favor different APIs, nats.js is going on strong with over 250K downloads/month. I do have started a 2.0 version of nats.js which addresses the shortcomings in the API while maintaining the event-driven nature of the library.