Skip to content

dbiele/TypeScriptEventDispatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

TypeScriptEventDispatcher

TypeScript + CreateJS EventDispatcher

Conversion of the CreateJS EventDispatcher to TypeScript format.

Example Use:

import {EventDispatcher} from 'folder/location/createjseventdispatcher';
import {Event} from 'folder/location/createjsevent';
export class deviceOrientation extends EventDispatcher {
    constructor() {
        super();
        // wait 2 seconds and then fire testDispatch
        setTimeout(() = > {this.testDispatch();}, 2000);
    }
    testDispatch():void {
        this.dispatchEvent(new Event("change", false, false));          
      }
}

// This is the starting function
export function appExternalModuleTest(): void {
    let _deviceOrientation: deviceOrientation;
    _deviceOrientation = new deviceOrientation();
    _deviceOrientation.addEventListener("change", () => this.changeOrientation());
    //_deviceOrientation.on("progress", () => this.changeOrientation());
}

export function changeOrientation(event: Event): void {
    console.log('orienationHasChanged ');
}

Notes

No need for d.ts files. Code is written in TypeScript.

CreateJS original source code: https://github.com/CreateJS/EaselJS/tree/master/src/createjs/events

About

TypeScript + EventDispatcher

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published