nats.docs
nats.docs copied to clipboard
Nats documentation for javascript and typescript outdated
Hello, I was following the documentation on nats for typescript but the code is completely outdated. An example would be the code for asynchronous subscription: Docs version:
nc.subscribe("updates", (err, msg) => {
if(err) {
console.log('error', err);
} else {
t.log(msg.data);
}
});
Library repository version
const { connect, StringCodec } = require("nats");
// to create a connection to a nats-server:
const nc = await connect({ servers: "demo.nats.io:4222" });
// create a codec
const sc = StringCodec();
// create a simple subscriber and iterate over messages
// matching the subscription
const sub = nc.subscribe("hello");
(async () => {
for await (const m of sub) {
console.log(`[${sub.getProcessed()}]: ${sc.decode(m.data)}`);
}
console.log("subscription closed");
})();
Is there any plan to update the docs for these ?
👋 hello @lukadriel7 ! Yes, just speaking of this yesterday. Our engineer just updated the examples in the repo but they have not been populated to docs yet. You can find the repo here https://github.com/nats-io/node-nats-examples
@gcolliso Thank you very much, I will take a look