Improve types (#25654)

This commit is contained in:
Jimi (Dimitris) Charalampidis
2018-05-09 11:24:55 -07:00
committed by Sheetal Nandi
parent e199aed403
commit 98a5d96dad
2 changed files with 15 additions and 14 deletions
+11 -11
View File
@@ -1,6 +1,7 @@
// Type definitions for stompjs 2.3
// Project: https://github.com/jmesnil/stomp-websocket
// Definitions by: Jimi Charalampidis <https://github.com/jimic>, Stefan Erichsen <https://github.com/Dr4k4n>
// Definitions by: Jimi Charalampidis <https://github.com/jimic>
// Stefan Erichsen <https://github.com/Dr4k4n>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -9,7 +10,7 @@ export const VERSIONS: {
V1_0: string,
V1_1: string,
V1_2: string,
supportedVersions: () => Array<string>
supportedVersions: () => string[]
};
export class Client {
@@ -31,8 +32,8 @@ export class Client {
disconnect(disconnectCallback: () => any, headers?: {}): any;
send(destination: string, headers?: {}, body?: string): any;
subscribe(destination: string, callback?: (message: Message) => any, headers?: {}): any;
unsubscribe(id: string): any;
subscribe(destination: string, callback?: (message: Message) => any, headers?: {}): Subscription;
unsubscribe(id: string): void;
begin(transaction: string): any;
commit(transaction: string): any;
@@ -42,23 +43,22 @@ export class Client {
nack(messageID: string, subscription: string, headers?: {}): any;
}
export interface Message {
command: string;
headers: {};
body: string;
export interface Subscription {
id: string;
unsubscribe(): void;
}
export interface Message extends Frame {
ack(headers?: {}): any;
nack(headers?: {}): any;
}
export class Frame implements Message {
export class Frame {
command: string;
headers: {};
body: string;
constructor(command: string, headers?: {}, body?: string);
ack(headers?: {}): any;
nack(headers?: {}): any;
toString(): string;
static sizeOfUTF8(s: string): number;
static unmarshall(datas: any): any;
+4 -3
View File
@@ -61,10 +61,11 @@ client.send('destination');
client.send('destination', {});
client.send('destination', {}, 'body');
client.subscribe('destination', (message) => { });
client.subscribe('destination', (message) => { }, {});
let subscription = client.subscribe('destination', (message) => { });
subscription = client.subscribe('destination', (message) => { }, {});
subscription.unsubscribe();
client.unsubscribe('id');
client.unsubscribe(subscription.id);
client.begin('transaction');