Skip to content

Commit

Permalink
Merge pull request #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 committed Oct 18, 2018
2 parents 983c71d + b0d8c23 commit 1684819
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
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 @@ -141,6 +143,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
Expand Up @@ -71,7 +71,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 @@ -119,12 +118,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 @@ -134,9 +133,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 1684819

Please sign in to comment.