m

    mattinger

    9 months ago
    So i’m trying to use anvil to build a 3 layer application graph where different libraries can contribute. I plan on having a shared set of scopes: • ApplicationScope • ActivityScope • FragmentScope I can use ContributesTo to add inject methods to the scopes, but i’m curious what’s the best way to get hold of the actual instances, since the host app would be the one that would know about the actual factories. I was thinking of defining the components in the library as well, but not running the anvil compiler there and instead just running it in the host app.
    The problem is that anvil is not processing the @MergeComponent annotations from my library when it run thes compiler in the host app.
    I’m really hoping to sort of replicate what hilt is doing by having 3 main components that are well known
    u

    ursus

    9 months ago
    I dont know your code but I'd expect you to just use constructors to get dependencies. Need a sample
    m

    mattinger

    9 months ago
    It’s just how anvil works. It will search the classpath for the things like @ContributesTo, but it won’t process @MergeComponent and @MergeSubcomponent unless the class is in the current compilation unit. I confirmed that with the devs.
    u

    ursus

    9 months ago
    Thats true but are you creating such component inside a library? I'd expect you to not need to, or use partial component if you only need to get values