-
-
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
Made StateKeeper#saveable type nullable #190
Conversation
WalkthroughThe pull request introduces significant enhancements to the state management functionality in the Essenty library, focusing on the Changes
Sequence DiagramsequenceDiagram
participant Client
participant StateKeeper
participant Serializer
participant PropertyDelegate
Client->>StateKeeper: saveable(serializer, init)
StateKeeper->>Serializer: Create serialization strategy
StateKeeper->>PropertyDelegate: Create property delegate
PropertyDelegate-->>Client: Return configurable property
Possibly related PRs
Poem
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt (1)
Line range hint
11-48
: Consider documenting thread-safety guaranteesThe documentation is comprehensive with good examples, but it would be helpful to mention the thread-safety guarantees provided by the implementation.
Add a note about thread-safety to the documentation:
* @param init a function that accepts the previously saved state [S] (if any) and * returns an object of type [T]. * @return [PropertyDelegateProvider] of type [T], typically used to define a delegated property. + * + * Thread-safety: The state holder implementation is thread-safe, ensuring visibility of state changes across threads. */state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExtTest.kt (2)
26-38
: Consider adding edge case testsThe tests cover basic nullable state handling well, but consider adding tests for:
- Switching between null and non-null values multiple times
- Concurrent state modifications
- Large state values
Also applies to: 54-80
82-95
: Consider testing more complex state scenariosThe test components are well-structured, but consider:
- Testing nested nullable states
- Testing collections with nullable elements
- Testing state restoration after process death
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
state-keeper/api/state-keeper.klib.api
(1 hunks)state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt
(6 hunks)state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExtTest.kt
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build on macOS
- GitHub Check: Build on Linux
🔇 Additional comments (3)
state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt (2)
154-162
: Well-implemented thread-safe state holder!The
Holder
class is well designed with:
- Thread-safe state management using
@Volatile
- Proper implementation of
ReadWriteProperty
interface- Clean serialization support via
@Serializable
49-61
: Clean implementation with proper null handling!The implementation correctly handles:
- Nullable state serialization
- Thread-safe state management
- Proper key generation for state saving
Also applies to: 141-152
state-keeper/api/state-keeper.klib.api (1)
44-47
: Well-designed API changes!The API changes:
- Properly support nullable types
- Maintain backward compatibility
- Provide consistent interfaces for both StateKeeper and StateKeeperOwner
Summary by CodeRabbit
New Features
Tests
Refactor