Skip to content

Commit

Permalink
Merge pull request mqttjs#872 from ogis-fujiwara/cb-store-put-ts
Browse files Browse the repository at this point in the history
Update TypeScript declaration files for `cbStorePut`.
  • Loading branch information
mcollina authored and redboltz committed May 19, 2019
1 parent a7ec0fb commit b7820d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions types/lib/client-options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { MqttClient } from './client'
import { Store } from './store'
import { QoS } from 'mqtt-packet'

export declare type StorePutCallback = () => void

export interface IClientOptions extends ISecureClientOptions {
port?: number // port is made into a number subsequently
host?: string // host does NOT include port
Expand Down Expand Up @@ -118,6 +120,10 @@ export interface IClientPublishOptions {
* whether or not mark a message as duplicate
*/
dup?: boolean
/**
* callback called when message is put into `outgoingStore`
*/
cbStorePut?: StorePutCallback
}
export interface IClientSubscribeOptions {
/**
Expand Down
9 changes: 4 additions & 5 deletions types/lib/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export declare type OnMessageCallback = (topic: string, payload: Buffer, packet:
export declare type OnPacketCallback = (packet: Packet) => void
export declare type OnErrorCallback = (error: Error) => void
export declare type PacketCallback = (error?: Error, packet?: Packet) => any
export declare type StorePutCallback = () => void
export declare type CloseCallback = () => void

export interface IStream extends events.EventEmitter {
Expand Down Expand Up @@ -90,12 +89,12 @@ export declare class MqttClient extends events.EventEmitter {
* @param {Object} [opts] - publish options, includes:
* @param {Number} [opts.qos] - qos level to publish on
* @param {Boolean} [opts.retain] - whether or not to retain the message
* @param {Function}[opts.cbStorePut] - function(){}
* called when message is put into `outgoingStore`
*
* @param {Function} [callback] - function(err){}
* called when publish succeeds or fails
*
* @param {Function} [cbStorePut] - function(){}
* called when message is put into outgoingStore
* @returns {Client} this - for chaining
* @api public
*
Expand All @@ -105,9 +104,9 @@ export declare class MqttClient extends events.EventEmitter {
* @example client.publish('topic', 'message', console.log)
*/
public publish (topic: string, message: string | Buffer,
opts: IClientPublishOptions, callback?: PacketCallback, cbStorePut?: StorePutCallback): this
opts: IClientPublishOptions, callback?: PacketCallback): this
public publish (topic: string, message: string | Buffer,
callback?: PacketCallback, cbStorePut?: StorePutCallback): this
callback?: PacketCallback): this

/**
* subscribe - subscribe to <topic>
Expand Down

0 comments on commit b7820d6

Please sign in to comment.