Magnet

General

Category
Free
Tag
Dependency Injections
License
N/A
Registered
Jul 22, 2018
Favorites
0
Link
https://github.com/beworker/magnet
See also
Toothpick
Kotter Knife
Dagger Play
ButterKnifeLite
DaggerAutoInject

Additional

Language
Java
Version
2.3 (Jul 8, 2018)
Created
Feb 27, 2018
Updated
Jul 8, 2018
Owner
Sergej Shafarenka (beworker)
Contributors
Sergej Shafarenka (beworker)
tbsandee
2
Activity
Badge
Generate
Download
Source code

Promotion

Magnet is a minimalist dependency injection and dependency inversion library for Android helping to write modular applications. If you need a simple, fast and non-intrusive dependency injection library, then Magnet is a good choice for you. It can also be interesting for growing Kotlin community because of its Kotlin-friendly API.

Magnet does not use reflection for object creation. It is based on annotation processor which prepares and partly validates dependency graph of your application at build-time. Final creation and validation of the dependency graph happens at runtime. This deliberate design decision esures a fair balance between fully statical and fully dynamic dependency injection. Properly designed Magnet-application allows adding and removing application functionality by adding and removing modules in application's build script whithout any additional programming effort. In that respect Magnet enforces modular design and helps modules be developed and tested in isolation.

Magnet is well documented and covered by unit tests.

Design

Magnet has a very minimalist, almost naive, design. It deals with just two concepts - Scopes and Instances. The whole design can be described by four simple statements:

  1. Scopes are containers for object Instances.
  2. Scopes can build up hierarchies.
  3. Instances can be put into (bound) and taken from Scopes.
  4. Instances can depend on other instances.

Documentation

  1. Developer Guide
  2. Dependency Inversion
  3. Hierarchical Scopes

Gradle

Kotlin

dependencies {
    api 'de.halfbit:magnet-kotlin:2.3'
    kapt 'de.halfbit:magnet-processor:2.3'
}

Java

dependencies {
    api 'de.halfbit:magnet:2.3'
    annotationProcessor 'de.halfbit:magnet-processor:2.3'
}

Proguard & R8

-keep class magnet.internal.MagnetIndexer { *; }

Support

Magnet is provided for free, without any support. If you consider using Magnet in your commercial product and you need support or training, feel free to contact me.

License

Copyright 2018 Sergej Shafarenka, www.halfbit.de

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.