oly
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

oly

Dependency injection, store and event emitter in one place.

oly is a module of the oly project.

import { Kernel } from "oly";
 
Kernel
  .create(/* store */)
  .with(/* services & providers */)
  .start()
  .catch(console.error)

Installation

$ npm install oly

Features

Injections

import { inject, Kernel } from "oly";
 
class A { text = "A" }
class B { text = "B" }
class C { @inject a: A }
 
Kernel
  .create()
  .with({provide: A, use: B})
  .get(C).a.text // B

Events

import { Kernel, on } from "oly";
 
class App {
  @on say = msg => console.log(msg)
}
 
Kernel
  .create()
  .with(App)
  .emit("App.say", "hello"); // hello

States

import { Kernel } from "oly";
 
Kernel
  .create({A: "B"})
  .on("oly:state:mutate", console.log)
  .kernel
  .state("A", "C"); // { key: 'A', newValue: 'C', oldValue: 'B' }

Readme

Keywords

Package Sidebar

Install

npm i oly

Weekly Downloads

22

Version

1.1.0

License

MIT

Unpacked Size

301 kB

Total Files

147

Last publish

Collaborators

  • nolyme