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

Feature request - support deferring to superclass component properties #351

Open
ZacSweers opened this issue Feb 12, 2024 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@ZacSweers
Copy link
Contributor

We have an example where we generate a component impl for a given class.

Scenario 1: declare parameter in the merge component, add property in impl

@MergeCircuitComponent(AppScope::class)
abstract class AppScopeCircuitComponent(@Component parent: AppComponent) : CircuitComponent

// Generated
abstract class AppScopeCircuitComponentImpl(@Component val parent: AppComponent) : AppScopeCircuitComponent(parent)

Scenario 2: declare property in the merge component, only add parameter in impl passed to parent

@MergeCircuitComponent(AppScope::class)
abstract class AppScopeCircuitComponent(@Component val parent: AppComponent) : CircuitComponent

// Generated
abstract class AppScopeCircuitComponentImpl(@Component parent: AppComponent) : AppScopeCircuitComponent(parent)

The latter feels preferably, but it seems only the former is supported. Curious if this is something that could be expanded or if there's a technical limitation.

Reference: slackhq/circuit#1197

@evant
Copy link
Owner

evant commented Feb 13, 2024

Seems like it should be doable, we already scan superclasses for @Provides we could scan for @Component as well. Actually may be worth spending some time seeing if we can unify how they are looked up, I can't remember off the top of my head why they are different.

note: I'd actually expect scenario 2 to look like

@MergeCircuitComponent(AppScope::class)
abstract class AppScopeCircuitComponent(@Component val parent: AppComponent) : CircuitComponent

// Generated
abstract class AppScopeCircuitComponentImpl(parent: AppComponent) : AppScopeCircuitComponent(parent)

@evant evant added the enhancement New feature or request label Feb 13, 2024
@ZacSweers
Copy link
Contributor Author

Makes sense re: not having @Component in the generated component, I wasn't sure when I was writing this up 👍

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