Преглед на файлове

Update Readme

tags/ci-01
garrettmills преди 7 месеца
родител
ревизия
6b68a6acff
No known key found for this signature in database GPG ключ ID: 6ACD58D6ADACFC6E
променени са 1 файла, в които са добавени 25 реда и са изтрити 8 реда
  1. +25
    -8
      README.md

+ 25
- 8
README.md Целия файл

@@ -3,9 +3,9 @@

The Flitter framework is a sophisticated, service-based framework for building web applications. In an attempt to keep the functionality provided by this framework modular and reusable, its functionality is broken down into services called Units. These Units are run in a particular order to start your Flitter application.

Flitter-DI is the second-generation dependency-injector used by Flitter to make this work. It was pulled from the [libflitter project](https://git.garrettmills.dev/flitter/libflitter) in the hope that it can remain independent from the rest of Flitter and can be used in other projects.
Flitter-DI is the second-generation inversion-of-control dependency-injector used by Flitter to make this work. It was pulled from the [libflitter project](https://git.garrettmills.dev/flitter/libflitter) in the hope that it can remain independent from the rest of Flitter and can be used in other projects.

Injectable classes specify a static array of service names. Then, these static classes are run through the `DependencyInjector#make()` method which injects instances of the requested services. Flitter-DI supports a robust, single-instance, cyclically-dependent service structure.
Injectable classes specify a static array of service names. Then, these static classes are run through the `DependencyInjector#inject()` method which injects instances of the requested services. Flitter-DI supports a robust, single-instance, cyclically-dependent service structure.

## Quick Start
#### Install with Yarn
@@ -63,10 +63,10 @@ useful.run() // Hello, World!
Alternatively, we can fetch services from the dependency injector directly:
```javascript
// Fetch the service directly
di.service('hello_world').hi() // Hello, World!
di.get('hello_world').hi() // Hello, World!

// Or use the service object
const service = di.service()
const service = di.proxy()
service.hello_world.hi() // Hello, World!
```

@@ -90,7 +90,7 @@ class B extends Service {
const container = new Container({ a: A, b: B })
const di = new DependencyInjector(container)

const service = di.service()
const service = di.proxy()

service.a // A { }
service.a.b // B { }
@@ -121,10 +121,9 @@ class MyClass extends Injectable {
}

const di = new DependencyInjector()
di.container.register('a', A)
di.container.register_service('a', A)

di.make(MyClass)
const my_class = new MyClass()
const my_class = di.make(MyClass)

console.log(my_class.a) // => A { number: 3.141 }
console.log(my_class.b) // => B { }
@@ -140,6 +139,24 @@ class BuzzKill extends Injectable {
}
```

### Singletons
Because `flitter-di` provides full IoC, you can register and use singletons with the dependency container like so:

```js
di.container.register_singleton('math_pi', 3.1415)

di.get('math_pi') // => 3.1415

class MathClass extends Injectable {
static get services() {
return ['math_pi']
}
}

const math = di.make(MathClass)
math.math_pi // => 3.1415
```

## License
Copyright 2019 Garrett Mills



Зареждане…
Отказ
Запис