add rails actioncable definition files

This commit is contained in:
Vincent Zhu
2016-03-17 17:06:10 +08:00
parent 926711691d
commit 03d98dd350
2 changed files with 35 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
/// <reference path="./actioncable.d.ts" />
App = {};
App.cable = ActionCable.createConsumer();
App.cable.subscriptions.create("NetworkChannel", {});
+31
View File
@@ -0,0 +1,31 @@
// Type definitions for ActionCable
// Project: https://github.com/rails/rails/tree/master/actioncable
// Definitions by: [Vincent Zhu] <https://github.com/zhu1230>
// Definitions: https://github.com/zhu1230/DefinitelyTyped
declare module ActionCable {
interface Channel {
unsubscribe(): void;
perform(action: string, data: {}): void;
}
interface Subscriptions {
create(chan_name: string, obj: {}): Channel;
}
interface Cable {
subscriptions: Subscriptions;
}
function createConsumer(): Cable;
function createConsumer(url: string): Cable;
}
declare interface AppInterface {
cable?: ActionCable.Cable;
network?: ActionCable.Channel;
}
declare var App: AppInterface;