@@ -201,7 +201,7 @@ simply to illustrate not only how to create responses, but how the subject
201
201
itself is used to dispatch different behaviors.
202
202
203
203
``` javascript
204
- import { connect , StringCodec , Subscription } from " nats" ;
204
+ import { connect , StringCodec } from " nats" ;
205
205
206
206
// create a connection
207
207
const nc = await connect ({ servers: " demo.nats.io" });
@@ -210,8 +210,8 @@ const nc = await connect({ servers: "demo.nats.io" });
210
210
const sc = StringCodec ();
211
211
212
212
// this subscription listens for `time` requests and returns the current time
213
- const sub = nc .subscribe (" time" );
214
- (async (sub : Subscription ) => {
213
+ const subscription = nc .subscribe (" time" );
214
+ (async (sub ) => {
215
215
console .log (` listening for ${ sub .getSubject ()} requests...` );
216
216
for await (const m of sub ) {
217
217
if (m .respond (sc .encode (new Date ().toISOString ()))) {
@@ -221,7 +221,7 @@ const sub = nc.subscribe("time");
221
221
}
222
222
}
223
223
console .log (` subscription ${ sub .getSubject ()} drained.` );
224
- })(sub );
224
+ })(subscription );
225
225
226
226
// this subscription listens for admin.uptime and admin.stop
227
227
// requests to admin.uptime returns how long the service has been running
@@ -276,7 +276,7 @@ Here's a simple example of a client making a simple request from the service
276
276
above:
277
277
278
278
``` javascript
279
- import { connect , StringCodec } from " nats" ;
279
+ import { connect , Empty , StringCodec } from " nats" ;
280
280
281
281
// create a connection
282
282
const nc = await connect ({ servers: " demo.nats.io:4222" });
0 commit comments