mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
add sharedworker/SharedWorker.d.ts
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
///<reference path="SharedWorker.d.ts" />
|
||||
|
||||
var worker_with_name = new SharedWorker('worker.js', "worker");
|
||||
|
||||
var worker = new SharedWorker('worker.js');
|
||||
|
||||
worker.port.onmessage = function(e) {
|
||||
console.log(e);
|
||||
};
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// Type definitions for SharedWorker
|
||||
// Project: http://www.w3.org/TR/workers/
|
||||
// Definitions by: Toshiya Nakakura <https://github.com/nakakura>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module SharedWorker {
|
||||
interface AbstractWorker extends EventTarget {
|
||||
onerror: (ev: ErrorEvent) => any;
|
||||
}
|
||||
|
||||
export interface SharedWorker extends AbstractWorker {
|
||||
/**
|
||||
* the value it was assigned by the object's constructor.
|
||||
* It represents the MessagePort for communicating with the shared worker.
|
||||
* @type {MessagePort}
|
||||
*/
|
||||
port: MessagePort;
|
||||
}
|
||||
}
|
||||
|
||||
declare var SharedWorker: {
|
||||
prototype: SharedWorker.SharedWorker;
|
||||
/***
|
||||
*
|
||||
* @param {string} stringUrl Pathname to JavaScript file
|
||||
* @param {string} name Name of the worker to execute
|
||||
*/
|
||||
new (stringUrl: string, name?: string): SharedWorker.SharedWorker;
|
||||
};
|
||||
Reference in New Issue
Block a user