|
1 | 1 | # Changelog
|
2 | 2 |
|
| 3 | +## 0.10.0 [BREAKING] - 2021.01.15 |
| 4 | + |
| 5 | +### BREAKING CHANGES |
| 6 | + |
| 7 | +#### Container.remove signature change |
| 8 | + |
| 9 | +The `Container.remove` method from now accepts one ID or an array of IDs. |
| 10 | + |
| 11 | +```ts |
| 12 | +// Old format |
| 13 | +Container.remove(myServiceA, myServiceB); |
| 14 | + |
| 15 | +// New format |
| 16 | +Container.remove([myServiceA, myServiceB]); |
| 17 | +``` |
| 18 | + |
| 19 | +#### Removed support for calling `Service([depA, depB], factory)` |
| 20 | + |
| 21 | +This was an undocumented way of calling the `Service` function directly instead of using it as a decorator. This option |
| 22 | +has been removed and the official supported way of achieving the same is with `Container.set`. Example: |
| 23 | + |
| 24 | +```ts |
| 25 | +const myToken = new Token('myToken'); |
| 26 | + |
| 27 | +Container.set(myToken, 'test-value'); |
| 28 | + |
| 29 | +// Old format: |
| 30 | +const oldWayService = Service([myToken], function myFactory(myToken) { |
| 31 | + return myToken.toUpperCase(); |
| 32 | +}); |
| 33 | +const oldResult = Container.get(oldWayService); |
| 34 | +// New format |
| 35 | +const newWayService = Container.set({ |
| 36 | + // ID can be anything, we use string for simplicity |
| 37 | + id: 'my-custom-service', |
| 38 | + factory: function myFactory(container) { |
| 39 | + return container.get(myToken).toUppserCase(); |
| 40 | + }, |
| 41 | +}); |
| 42 | +const newResult = Container.get('my-custom-service'); |
| 43 | + |
| 44 | +oldResult === newResult; // -> true, both equals to "TEST-VALUE" |
| 45 | +``` |
| 46 | + |
| 47 | +### Added |
| 48 | + |
| 49 | +- added `eager` option to `ServiceOptions`, when enabled the class will be instantiated as soon as it's registered in the container |
| 50 | +- added support for destroying removed services, when a service is removed and has a callable `destroy` property it will be called by TypeDI |
| 51 | + |
| 52 | +### Changed |
| 53 | + |
| 54 | +- [BREAKING] removed old, undocumented way of calling `@Service` decorator directly |
| 55 | +- [BREAKING] renamed `MissingProvidedServiceTypeError` to `CannotInstantiateValueError` |
| 56 | +- various internal refactors |
| 57 | +- updated various dev dependencies |
| 58 | + |
| 59 | +### Fixed |
| 60 | + |
| 61 | +- generated sourcemaps contains the Typescript files preventing reference errors when using TypeDI with various build tools |
| 62 | + |
3 | 63 | ## 0.9.1 - 2021.01.11
|
4 | 64 |
|
5 | 65 | ### Fixed
|
|
0 commit comments