mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Merge pull request #19643 from gjoshevski/signalr-no-jquery
Added type definitions for signalr-no-jquery
This commit is contained in:
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
// Type definitions for signalr-no-jquery 0.1
|
||||
// Project: https://github.com/DVLP/signalr-no-jquery/
|
||||
// Definitions by: Martin Gjoshevski <https://github.com/gjoshevski>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export function hubConnection(url?: string, options?: Options): Connection;
|
||||
|
||||
export function signalR(url?: string, qs?: any, logging?: any): any;
|
||||
|
||||
export interface Connection {
|
||||
id: string;
|
||||
proxies: { [hubName: string]: any };
|
||||
transport: {
|
||||
name: string,
|
||||
supportsKeepAlive: SupportsKeepAliveHandler
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new proxy object for the given hub connection that can be used to invoke
|
||||
* methods on server hubs and handle client method invocation requests from the server.
|
||||
*
|
||||
* @param hubName The name of the hub on the server to create the proxy for.
|
||||
*/
|
||||
createHubProxy(hubName: string): Proxy;
|
||||
|
||||
start(options?: any, callback?: any): any;
|
||||
}
|
||||
|
||||
export interface Proxy {
|
||||
state: any;
|
||||
connection: Connection;
|
||||
hubName: string;
|
||||
init(connection: Connection, hubName: string): void;
|
||||
hasSubscriptions(): boolean;
|
||||
/**
|
||||
* Wires up a callback to be invoked when a invocation request is received from the server hub.
|
||||
*
|
||||
* @param eventName The name of the hub event to register the callback for.
|
||||
* @param callback The callback to be invoked.
|
||||
*/
|
||||
on(eventName: string, callback: (...msg: any[]) => void): Proxy;
|
||||
/**
|
||||
* Removes the callback invocation request from the server hub for the given event name.
|
||||
*
|
||||
* @param eventName The name of the hub event to unregister the callback for.
|
||||
* @param callback The callback to be invoked.
|
||||
*/
|
||||
off(eventName: string, callback: (...msg: any[]) => void): Proxy;
|
||||
/**
|
||||
* Invokes a server hub method with the given arguments.
|
||||
*
|
||||
* @param methodName The name of the server hub method.
|
||||
*/
|
||||
invoke(methodName: string, ...args: any[]): Promise<any>;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
qs?: string;
|
||||
logging?: boolean;
|
||||
useDefaultPath?: boolean;
|
||||
}
|
||||
|
||||
export type SupportsKeepAliveHandler = () => boolean;
|
||||
@@ -0,0 +1,14 @@
|
||||
import { hubConnection } from 'signalr-no-jquery';
|
||||
|
||||
const connection = hubConnection('http://[address]:[port]');
|
||||
const hubProxy = connection.createHubProxy('hubNameString');
|
||||
|
||||
// set up event listeners i.e. for incoming "message" event
|
||||
hubProxy.on('message', (message) => {
|
||||
console.log(message);
|
||||
});
|
||||
|
||||
// connect
|
||||
connection.start({ jsonp: true })
|
||||
.done(() => { console.log('Now connected, connection ID=' + connection.id); })
|
||||
.fail(() => { console.log('Could not connect'); });
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"signalr-no-jquery-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user