$ npm i --save natsx
The main purpose of the library is to manage nats subscription behavior with RxJS operators like
You can pass a nats client or use connect() method of NatsX to initalize the wrapper
To unsubscribe from nats subscription, you must unsubscribe from the observable with operators or manually.
// that will get 3 greeting messages then unsubscribe from nats subscriptionclient.from'greeting'.pipetake3.subscribe
To achieve the same ability for nats requests, we are not using the ts-nats request method directly. You must manage your subscription same way of
from method of NatsX
// that will wait a response for 2 seconds then throw timeout error and unsubscribe from reply subject.client.request'greeter', 'me'.pipetimeout2000.subscribe
Also, you can use other methods like
drain and listen the connection status with
status$, and other nats events with
You are welcome to contribute to this project, just open a PR.
- NatsX is MIT licensed.