Skip to content

Instantly share code, notes, and snippets.

@josh-burton
Created April 25, 2017 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josh-burton/68f842d3d00ca770b4a85b40c0e1c995 to your computer and use it in GitHub Desktop.
Save josh-burton/68f842d3d00ca770b4a85b40c0e1c995 to your computer and use it in GitHub Desktop.
Context with @BindsInstance
DaggerApplicationComponent.builder().context(applicationContext).build().inject(this);
@Component(modules = {Module.class})
public interface Component {
@Component.Builder
interface Builder {
@BindsInstance
Builder context(Context context);
Component build();
}
}
@Module
abstract class ApplicationModule {
@Provides
public static Dependency provideDependencyNeedingContext(Context context) {
//create dependency
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment