Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile time dependencies check #234

Open
epool opened this issue Sep 8, 2022 · 1 comment
Open

Compile time dependencies check #234

epool opened this issue Sep 8, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@epool
Copy link

epool commented Sep 8, 2022

let's say I have a composable with some dependencies.

@RootNavGraph
@Composable
@Destination
fun SomeScreen(
    dependency1: Dependency1,
    dependency2: Dependency2,
)

...

DestinationsNavHost(
    navGraph = NavGraphs.root,
    dependenciesContainerBuilder = {
        dependency(dependency1)
        // dependency(dependency2) force a compile error if we forget to satisfy this dependency.
    },
)

is there a way to ensure that the dependencies of the above composable are satisfied at compile time like dagger/hilt does instead of doing it at runtime?

this to avoid forgetting to pass the dependency and realise about it once the whole project has been compiled and run.

@raamcosta
Copy link
Owner

Hi!

I already thought of this, but the thing is people can choose to manually call their Composables, at which point it's really impossible to tell at compile time whether there is a missing dependency or the developer is just doing that (calling it manually).
Maybe we could use some other annotation to explicitly tell the library that we're doing that..

I'll keep this open as a possible future enhancement.
I also don't think that this is a major issue as the app crashes at the earliest chance and the developer will surely notice it once they run the app. As you said, the only issue is losing some time for builds..

@raamcosta raamcosta added the enhancement New feature or request label Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants