-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Deprecated InstanceKeeper#getOrCreate, added InstanceKeeper#provide and InstanceKeeper#providing extension functions #161
Conversation
WalkthroughThe Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (4)
- instance-keeper/api/android/instance-keeper.api (1 hunks)
- instance-keeper/api/jvm/instance-keeper.api (1 hunks)
- instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExt.kt (2 hunks)
- instance-keeper/src/commonTest/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExtTest.kt (1 hunks)
Additional comments: 16
instance-keeper/src/commonTest/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExtTest.kt (4)
- 13-15: The test
WHEN_provide_with_key_called_second_time_THEN_returns_same_instance
correctly verifies that theprovide
function returns the same instance when called with the same key. This aligns with the expected behavior of theprovide
function, ensuring instance uniqueness per key.- 21-23: The test
WHEN_provide_without_key_called_second_time_THEN_returns_same_instance
effectively checks that theprovide
function without a specified key behaves as expected, returning the same instance upon subsequent calls. This test is crucial for validating the default key behavior of theprovide
function.- 29-31: The test
WHEN_provideSimple_with_key_called_second_time_THEN_returns_same_instance
accurately ensures thatprovideSimple
with a key returns the same instance on repeated calls. This test is essential for verifying the correct behavior of theprovideSimple
function, which is intended for simpler use cases without the need for instance destruction.- 37-39: The test
WHEN_provideSimple_without_key_called_second_time_THEN_returns_same_instance
confirms thatprovideSimple
without an explicit key returns the same instance on subsequent calls. This test validates the behavior ofprovideSimple
in scenarios where a key is not provided, ensuring consistency with the expected functionality.instance-keeper/api/jvm/instance-keeper.api (1)
- 32-35: The addition of
provide
,provideSimple
,providing
, andprovidingSimple
functions to theInstanceKeeperExtKt
class is correctly implemented. These functions extend the functionality of theInstanceKeeper
component, offering more flexible and intuitive options for instance management. It's important to ensure that these functions are well-documented and their usage is clear to developers.instance-keeper/api/android/instance-keeper.api (1)
- 39-42: The addition of
provide
,provideSimple
,providing
, andprovidingSimple
functions to theInstanceKeeperExtKt
for the Android target mirrors the changes made for the JVM target. This consistency across platforms is crucial for a unified developer experience. Ensure that these functions are accompanied by appropriate documentation and examples to facilitate their adoption.instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExt.kt (10)
- 9-18: The deprecation of
getOrCreate
in favor ofprovide
is correctly implemented with a clear deprecation message and aReplaceWith
action. This approach facilitates a smooth transition for developers to the new API.- 24-24: The
provide
function is well-implemented, ensuring type safety and correct instance management. It's important to maintain comprehensive documentation for this function, explaining its behavior and usage scenarios.- 39-40: The lazy variant
providing
is correctly implemented, offering a deferred instance creation option. This addition enhances the flexibility of theInstanceKeeper
component. Ensure that the lazy behavior is clearly documented for developers.- 46-55: The deprecation of
getOrCreate
for the reified type variant in favor ofprovide
is correctly handled, with a clear message andReplaceWith
directive. This consistency in deprecation strategy across different function variants is commendable.- 61-62: The reified type variant of
provide
is correctly implemented, leveraging Kotlin's reified type parameters for a more intuitive API. Documentation should clearly explain the use of reified types and the benefits they offer in this context.- 77-86: The deprecation of
getOrCreateSimple
in favor ofprovideSimple
is handled well, with a clear deprecation message and aReplaceWith
action. This change aligns with the overall goal of improving the API's intuitiveness and consistency.- 94-96: The
provideSimple
function is implemented correctly, catering to simpler use cases where instance destruction is not required. It's crucial to document this function's intended use cases and limitations clearly.- 104-105: The lazy variant
providingSimple
is a valuable addition, offering deferred creation for simple instances. Documentation should highlight the lazy behavior and its potential use cases to guide developers effectively.- 113-122: The deprecation of
getOrCreateSimple
for reified types in favor ofprovideSimple
is consistent with the deprecation strategy applied to other variants. This clear and consistent approach aids developers in transitioning to the new API.- 130-131: The reified type variant of
provideSimple
is well-implemented, providing a straightforward API for simple instance management. Ensure that the benefits of using reified types in this context are well-documented.
…nd InstanceKeeper#providing extension functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (5)
- instance-keeper/api/android/instance-keeper.api (1 hunks)
- instance-keeper/api/jvm/instance-keeper.api (1 hunks)
- instance-keeper/src/androidUnitTest/kotlin/com/arkivanov/essenty/instancekeeper/AndroidInstanceKeeperTest.kt (3 hunks)
- instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExt.kt (2 hunks)
- instance-keeper/src/commonTest/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExtTest.kt (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- instance-keeper/api/android/instance-keeper.api
- instance-keeper/api/jvm/instance-keeper.api
- instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExt.kt
- instance-keeper/src/commonTest/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExtTest.kt
Additional comments: 3
instance-keeper/src/androidUnitTest/kotlin/com/arkivanov/essenty/instancekeeper/AndroidInstanceKeeperTest.kt (3)
- 17-20: The replacement of
getOrCreate
withprovide
in theretains_instances
test method aligns well with the PR objectives, ensuring that instances are managed more intuitively. The test logic correctly verifies that instances are retained across differentinstanceKeeper
calls.- 29-32: The test
GIVEN_discardRetainedInstances_is_true_on_restore_THEN_instances_not_retained
correctly verifies that instances are not retained whendiscardRetainedInstances
is set to true. The use ofprovide
for instance creation is consistent with the PR's objectives and enhances the clarity of instance management.- 41-41: The test
GIVEN_discardRetainedInstances_is_true_on_restore_THEN_old_instances_destroyed
effectively ensures that old instances are destroyed whendiscardRetainedInstances
is true, aligning with the PR's focus on efficient instance management. The adoption ofprovide
for instance creation is appropriate and supports the PR's goals.
Summary by CodeRabbit
InstanceKeeper
module, enhancing flexibility and usability.getOrCreate
functions in favor of new, more intuitively namedprovide
functions, including lazy variants for deferred instance creation.