base-class-patterns

0.0.3 • Public • Published

Basic class pattern. On that moment just Singleton 😄 If you have any suggestion/ideas/question please contact me on github or email

npm install base-class-patterns

For test run:

npm run test

For generate docs:

npm run doc

Singleton

You may use Singleton pattern like:

import {Singleton} from 'base-class-patterns';

class childSingleton extends Singleton {
  
  inc() {
    this.counter = this.counter ? this.counter += 1 : 1;
  }

  static getInstance() {
    return super.getInstance(this);
  }
}

You need to override method getInstance() from base class, at least call the base method

return super.getInstance(this);

Package Sidebar

Install

npm i base-class-patterns

Weekly Downloads

2

Version

0.0.3

License

ISC

Unpacked Size

4.73 kB

Total Files

9

Last publish

Collaborators

  • iceflash