Code Monkey home page Code Monkey logo

daggerobj's Introduction

dagger.obj

dagger.android 只能注入到 Android,Fragment,Service…等类中,但在某些特殊情况下我们需要注入到其他类中,但 dagger.android 并不支持,故而有了此库:

参考 Dagger AndroidSupport写法,使得DaggerAndroid 能注入到任何类中

原理

说到底,dagger.android 是将所有的实例都提供给了 Application(通过 Provider 实现懒加载),AndroidInjection.inject(this);实际上就是去 Application 去取实例,然后注入到被注入对象中的。

所以,dagger.obj 做的事情就是将 Application 中的实例注入到普通 Object 中,和 dagger.android.support中对 android.support.v4.app.Fragment 的支持类似。

使用

和 dagger.android.support 类似,只是使用 AndroidObjInjection.inject(this); 注入就行了。

daggerobj's People

Contributors

hurshi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.