Added definitions for ng-stomp library

This commit is contained in:
Lukasz Potapczuk
2015-11-24 12:11:19 +01:00
parent ba424f7ee3
commit 612f58ac6a
2 changed files with 82 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="ng-stomp.d.ts" />
module ngStompTesting {
"use strict";
var ngStompTest = "ngStompTest";
class test {
constructor(private ngstomp:ngStomp) {
var connectHeaders ={
"Lol": "user",
"Accept": "lol"
};
ngstomp.connect('/endpoint', connectHeaders)
// frame = CONNECTED headers
.then(function (frame) {
this.subscription = ngstomp.subscribe('/dest', function (payload, headers, res) {
this.payload = payload;
}, {
"headers": "are awesome"
});
// Unsubscribe
this.subscription.unsubscribe();
// Send message
ngstomp.send('/dest', {
message: 'body'
}, {
priority: 9,
custom: 42 //Custom Headers
});
// Disconnect
ngstomp.disconnect(function () {
});
});
}
}
angular.module("app").controller(ngStompTest, test);
}
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for ngStomp
// Project: https://github.com/beevelop/ng-stomp
// Definitions by: Lukasz Potapczuk
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
interface ngStomp {
sock:any;
stomp:any;
debug:any;
off: any;
setDebug:(callback:Function)=> void;
connect: (endpoint:string, headers?:Headers)=> angular.IHttpPromise<any>;
disconnect: (callback:()=>void) => angular.IHttpPromise<any>;
subscribe: (destination:string, callback:Function, headers?:Headers, scope?:any) => any;
unsubscribe: () => any;
send: (destination:string, body:any, headers:Headers)=> any;
}
interface Headers {
[key: string]: any;
}