4.0.0 • Published 6 months ago

@flect/ioc v4.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Introduction

Flect/ioc is a library for building and resolving a dependency graph.

Usage

const Animal = record({
	legCount: numberType,
	sound: stringType
});
type Animal = Reify<typeof Animal>;

const Person = record({
	pet: record({
		legCount: numberType,
		sound: stringType
	})
});
type Person = Reify<typeof Person>;

class Cat implements Animal {
	get legCount() {
		return 4;
	}
	get sound() {
		return "meow";
	}
}

const c = new Container();
c.bind(Person)
	.with(Animal)
	.toFactory((a: Animal) => ({pet: a}));
c.bind(Animal).toFactory(() => new Cat());

console.log(c.resolve(Person).pet.sound); // Goes 'woof'
4.0.0

6 months ago

3.3.0

7 months ago

3.2.0

7 months ago

3.1.0

7 months ago

3.0.1

8 months ago

3.0.0

8 months ago

2.0.0

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago