Skip to content

luruke/bidello

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ‘¨β€πŸ« bidello

Don't leave your Class alone.

bidello is a simple class Mixin and event system.

How to use it

npm install bidello

and then

import { component } from 'bidello';

class YourClass extends component() {
  init() {
    //...
  }
}

And so?

You can extend your classes, and trigger methods by global events.

import bidello, { component } from 'bidello';

class YourClass extends component() {
  onResize({ width, height }) {

  }

  onVisibility({ visible }) {

  }

  onRaf() {

  }
};

// Anywhere else in your code...
bidello.trigger({ name: 'resize', fireAtStart: true }, {
  width: window.innerWidth,
  height: window.innerHeight,
});

bidello.trigger({ name: 'onVisibility' }, {
  visible: false,
});

bidello.trigger({ name: 'raf' });

The fireAtStart flag, if true, will force the onResize method to be called for any new classes created in the future (automatically passing the last known data)

Extending an existing class using bidello

You can also do stuff like:

import { Object3D } from 'three.js';
import { component } from 'bidello';

class YourClass extends component(Object3D) {
  onResize({ width, height }) {

  }

  onVisibility({ visible }) {

  }

  onRaf() {

  }
};

In this way YouClass extends Object3D plus bidello methods

Look at antipasto for a real example.

About

πŸ‘¨β€πŸ« Don't leave your Class alone

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published