Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

4.0.0

Compare
Choose a tag to compare
@auguwu auguwu released this 01 Jun 19:01
· 273 commits to master since this release

Additions

  • Subscriptions API πŸŽ‰
  • APIs for Components and Services πŸŽ‰

Deprecations

  • Container.runInjections(target) has been replaced with Container.addInjections(target).

APIs for Components and Services: What is that?

It's just a external class named api that has references to the container.

Subscriptions API: What is it?

It's a way to have methods emitted from component/service (or child!) components without external libraries or any implementation. You must register your emitter though or it'll not work! An example would be:

components/some-dummy.component.ts

import { Component, Subscribe } from '@augu/lilith';

@Component({ priority: 0, name: 'some-dummy' })
export default class MyDummyComponent {
   @Subscribe('some-event', 'a-event-emitter', false)
   onSomeEvent(a: string) {
       console.log('received: ' + a);
   }
}

main.ts

import { Container } from '@augu/lilith';
import { EventEmitter } from 'events';

const container = new Container({
   componentsDir: 'find your components here :D'
});

const emitter = new EventEmitter();
container.addEmitter('a-event-emitter', emitter);
(async() => {
    await container.load();
    emitter.emit('some-event', 'uwudog');
})();