I like to know what does a Promise<void>
mean? For example in the following code:
import { Stan } from 'node-nats-streaming';
import { Subjects } from './subjects';
interface Event {
subject: Subjects;
data: any;
}
export abstract class Publisher<T extends Event> {
abstract subject: T['subject'];
protected client: Stan;
constructor(client: Stan) {
this.client = client;
}
publish(data: T['data']): Promise<void> {
return new Promise((resolve, reject) => {
this.client.publish(this.subject, JSON.stringify(data), (err) => {
if (err) {
return reject(err);
}
console.log('Event published to subject', this.subject);
resolve();
});
});
}
}
The publish
method returns a Promise<void>
but as you can see the stan
publish method that has been used inside the publish
method should return a string like (method) Stan.publish(subject: string, data?: string | Uint8Array | Buffer | undefined, callback?: AckHandlerCallback | undefined): string
.
I can't understand what Promise<void>
looks like and how does it get matched with the expected string
that stan.publish():string
method should return?