Skip to content

Support for Lazy<T> like Dagger #852

@tavianator

Description

@tavianator

I've implemented a version of Dagger's Lazy<T> in Sangria. But it's somewhat limited; Lazy<Dependency> works automatically but @Annotated Lazy<Dependency> requires you to explicitly add a binding. That's about as good as an extension can do. There are some alternatives:

  1. Have Guice support its own Lazy<T> out of the box, in a similar way to how Provider<T> injection works now.
  2. Have Guice expose some kind of support for "pluggable bindings." Then I could write something like bind(new LazyKeyMatcher()).to(new LazyGuicePlugin()) and the plugin would generate bindings on the fly.

Is there any interest in doing something like 2? If so I can code up a proof of concept.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions