Skip to content

Cherry pick bug fix added to 0.7.8 #187

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

Merged
merged 1 commit into from
May 29, 2025
Merged

Cherry pick bug fix added to 0.7.8 #187

merged 1 commit into from
May 29, 2025

Conversation

ra1028
Copy link
Owner

@ra1028 ra1028 commented May 29, 2025

Pull Request Type

  • Bug fix
  • New feature
  • Refactoring
  • Documentation update
  • Chore

… is missing (#186)

* Refresh now uses a store with the current scope if cache is missing

* Fix compilation in Swift 5
@ra1028 ra1028 marked this pull request as ready for review May 29, 2025 05:02
@Copilot Copilot AI review requested due to automatic review settings May 29, 2025 05:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR cherry-picks a bug fix for the refresh behavior of atoms by adding new tests and refactoring the context-switching logic within StoreContext. Key changes include:

  • New tests for non-cached refresh behavior in both core and custom refreshable atoms.
  • Refactoring of StoreContext functions to replace switchContext(scope:) with switchContext(with:) for a more explicit use of AtomCache.
  • Adjustments in reset and update functions to work with the new switchContext(with:) API.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Tests/AtomsTests/Core/StoreContextTests.swift Adds a test for refresh using an override container to return a fixed value.
Tests/AtomsTests/Attribute/RefreshableTests.swift Introduces a custom refresh test for a refreshable atom using dependency overrides.
Sources/Atoms/Core/StoreContext.swift Refactors context switching by replacing switchContext(scope:) with switchContext(with:) and adjusts related calls accordingly.

@@ -647,11 +649,11 @@ private extension StoreContext {
}
}

func switchContext(scope: Scope?) -> StoreContext {
func switchContext(with cache: some AtomCacheProtocol) -> StoreContext {
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

Consider verifying that 'cache.initializedScope' will always provide a non-nil value. If there's any chance it could be nil, it might be beneficial to add an assertion or error handling to prevent propagation of an invalid context.

Copilot uses AI. Check for mistakes.

@ra1028 ra1028 merged commit b1e2ea2 into main May 29, 2025
6 checks passed
@ra1028 ra1028 deleted the cherry-pick-0.7.8 branch May 29, 2025 05:12
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.

1 participant