Skip to content

Commit

Permalink
chore(release): got things ready for a release
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsamwell committed Oct 26, 2020
1 parent 2685531 commit 1e9bb87
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
33 changes: 22 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
## [1.0.4] - 24/10/2020
* Made various code optimizations.
* Added a possibility for method chaining.
## [1.0.4] - 26/10/2020

* Various code optimizations.
* Api now allows for method chaining so make mapping more concise.
* Silent removing of non existing mappings (without throwing exceptions).
* The Injector class has a factory constructor now. An Injector instance can be instantiated
more shorter. `Injector.getInjector()` is marked as deprecated.
```dart
* The Injector class now has a factory constructor. An Injector instance can be instantiated
in a more concise way than `Injector.getInjector()` which is now marked as deprecated.

``` dart
// example with introduced changes
final injector = Injector();
injector.map<SomeType>((injector) => SomeType("0"))
Expand All @@ -13,28 +15,35 @@
```

## [1.0.3] - 11/08/2020

* Added the ability to remove a mapping and check if a mapping is present in the injector
```dart

``` dart
// the new api
final injector = Injector.getInstance();
injector.map<SomeType>((i) => new SomeType())
final instance = injector.get<SomeType>();
injector.removeMapping<SomeType>();
```

## [1.0.2+1] - 24/12/2019

* Fixed various analyzer warnings

## [1.0.2] - 18/12/2019

* Fixed some lint warnings

## [1.0.1] - 05/03/2019

* Removed dependency on flutter
* Updated example to explain how to use dependency injection rather than service location

## [0.0.4] - 05/07/2018

* Added ability to pass in additional arguments in the factory function with a new method call [mapWithParams].

```dart
``` dart
final injector = Injector.getInstance();
injector.mapWithParams<SomeType>((i, p) => new SomeType(p["id"]))
final instance = injector.get<SomeType>(additionalParameters: { "id": "some-id" });
Expand All @@ -43,7 +52,7 @@

* Added ability to get all objects of the same mapped type

```dart
``` dart
final injector = Injector.getInstance();
injector.map<SomeType>((injector) => new SomeType("0"));
injector.map<SomeType>((injector) => new SomeType("1"), key: "One");
Expand All @@ -57,15 +66,17 @@
* Improved injector interface using generic types instead of a passed in a type to key an object factory

The new api to map and get a type instance
```dart

``` dart
// the new api
final injector = Injector.getInstance();
injector.map<SomeType>((i) => new SomeType())
final instance = injector.get<SomeType>();
```

The old api to map and get a type instance
```dart

``` dart
// the old api
final injector = Injector.getInstance();
injector.map(SomeType, (i) => new SomeType())
Expand Down
2 changes: 1 addition & 1 deletion example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void main() {
final injector = ModuleContainer().initialise(Injector());

// NOTE: it is best to architect your code so that you never need to
// interact with the injector itself. Make this framework act like a depencendy injector
// interact with the injector itself. Make this framework act like a dependency injector
// by having dependencies injected into objects in their constructors. That way you avoid
// any tight coupling with the injector itself.

Expand Down
9 changes: 6 additions & 3 deletions lib/src/injector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class Injector {
/// Naming injectors enable each app to have multiple atomic injectors.
final String name;

@Deprecated('Prefer to use the factory constructor Injector([String name = "default"])')
@Deprecated(
'Prefer to use the factory constructor Injector([String name = "default"])')
static Injector getInjector([String name = 'default']) {
return Injector(name);
}
Expand All @@ -72,7 +73,8 @@ class Injector {

Injector._internal(this.name);

String _makeKey<T>(T type, [String key]) => '${_makeKeyPrefix(type)}${key ?? 'default'}';
String _makeKey<T>(T type, [String key]) =>
'${_makeKeyPrefix(type)}${key ?? 'default'}';

String _makeKeyPrefix<T>(T type) => '${type.toString()}::';

Expand Down Expand Up @@ -140,7 +142,8 @@ class Injector {
/// injector.map(Logger, (injector, params) => AppLogger(params["logKey"]));
/// injector.map(AppLogger, (injector, params) => AppLogger(injector.get(Logger, params["apiUrl"])), key: "AppLogger");
/// ```
Injector mapWithParams<T>(ObjectFactoryWithParamsFn<T> factoryFn, {String key}) {
Injector mapWithParams<T>(ObjectFactoryWithParamsFn<T> factoryFn,
{String key}) {
final objectKey = _makeKey(T, key);
if (_factories.containsKey(objectKey)) {
throw InjectorException("Mapping already present for type '$objectKey'");
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_simple_dependency_injection
description: A super simple dependency injection implementation for flutter that behaves like any normal IOC container and does not rely on mirrors
version: 1.0.3
version: 1.0.4
homepage: https://github.com/jonsamwell/flutter_simple_dependency_injection

dependencies:
Expand Down

0 comments on commit 1e9bb87

Please sign in to comment.