Merge pull request #8606 from zhu1230/master

add rails/actioncable definition files.
This commit is contained in:
Masahiro Wakame
2016-03-19 14:34:24 +09:00
2 changed files with 35 additions and 0 deletions
@@ -0,0 +1,4 @@
/// <reference path="./rails-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;