Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-base-class

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-base-class

base class to exntends

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30
increased by57.89%
Maintainers
1
Weekly downloads
 
Created
Source

BaseClass

Base class to extend. Like backbone events.

Installation

npm install ts-base-class --save

Interface path

/// <reference types="ts-base-class" />
For configure project:
npm install typescript -g
npm install tsd -g
npm run init 

For start test:
npm run test

Methods

  • on
  • once
  • off
  • listenTo
  • listenToOnce
  • stopListening
  • trigger
  • onLoad
  • loaded
  • onReady
  • ready
  • onState
  • setState
  • hasState
  • isLoaded
  • on(eventName:string, handler:IHandler, context?:any):Base;
  • once(eventName:string, handler:IHandler, context?:any):Base;
  • off(eventName?:string, handler?:IHandler):Base;
  • listenTo(target:Base, eventName:string, handler:IHandler, context?:any):Base;
  • listenToOnce(target:Base, eventName:string, handler:IHandler, context?:any):Base;
  • stopListening(target?:Base, eventName?:string, handler?:IHandler):Base;
  • trigger(eventName:string, args?:Array):Base;
  • onLoad(callback:Callback):Base;
  • loaded():Base;
  • onReady(callback:Callback):Base;
  • ready():Base;
  • onState(state:string, callback:Callback):Base;
  • setState(state:string):Base;
  • hasState(state:string):boolean;
  • isLoaded():boolean;

Example


     /// <reference types="ts-base-class" />
     import {Base} from 'ts-base-class';
     
     class MyClass extends Base {
        //...
        
     }
     
     var $class = new MyClass();
     
     $class.on("Some:change", function (arg) {
        console.log(this instanceof MyClass); //true
        console.log(arg); //1
     });
     
     $class.on("Some", function (state:string, arg) {
        console.log(this instanceof MyClass); //true
        console.log(state); //"change"
        console.log(arg); //1
     });
     
     $class.trigger("Some:change", [1]);


Version: 2.0.2


License

Licensed under ISC

Keywords

FAQs

Package last updated on 13 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc