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

Refactor FeatureFactory public API using Params. #398

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

Laimiux
Copy link
Collaborator

@Laimiux Laimiux commented Sep 25, 2024

What

I'm wrapping the dependencies and key into a Params object and updating FeatureFactory.initialize to get it via the extension function receiver type Params.initialize(): Feature.

Feature factory initialization changes from

override fun initialize(dependencies: Unit, key: Key): Feature

to

override fun Params.initialize(): Feature

Why

We need to pass FragmentId or something equivalent to the FeatureFactory. This change requires us to introduce a new parameter that would break existing usages. Instead of just adding a new parameter, I'm refactoring the way this public API works which will enable us to modify Params object in the future without breaking the usages.

@Laimiux Laimiux force-pushed the laimonas/feature-factory-refactor branch from 986242f to c88e76d Compare September 25, 2024 17:01
@carrotkite
Copy link

JaCoCo Code Coverage 97.15% ✅

Class Covered Meta Status
com/instacart/formula/android/FeatureFactory 100% 0%
com/instacart/formula/android/internal/MappedFeatureFactory 100% 0%

Generated by 🚫 Danger

Comment on lines -43 to +55
fun initialize(dependencies: Dependencies, key: Key): Feature
fun initialize(dependencies: Dependencies, key: Key): Feature {
return Params(dependencies, key).initialize()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this become private in a follow up?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, this function provides a better API to initialize the Feature. It's a final function that delegates to a better internal API for implementation.

  • for implentee use Params.initialize
  • for the consumer use initialize(dependencies, key, other params)

@Laimiux Laimiux merged commit 3ddba2a into master Sep 25, 2024
4 checks passed
@Laimiux Laimiux deleted the laimonas/feature-factory-refactor branch September 25, 2024 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants