8000 Big rewrite to make it distinct from SwiftUI Environment Values by hainayanda · Pull Request #22 · hainayanda/SwiftEnvironment · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Big rewrite to make it distinct from SwiftUI Environment Values #22

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 2 commits into from
May 31, 2025

Conversation

hainayanda
Copy link
Owner

This pull request introduces significant changes to the SwiftEnvironment library, focusing on refactoring its global environment management system. The changes include replacing EnvironmentValues with a new GlobalValues structure, updating documentation to reflect the new design, and removing deprecated files. These updates aim to simplify the codebase, enhance flexibility, and improve clarity in managing global environment values.

Refactoring Global Environment Management:

  • Introduction of GlobalValues: Added a new GlobalValues structure to replace the SwiftEnvironmentValues class. This structure introduces methods for managing singleton, transient, and weak global values, along with support for dynamic member lookup and publishers for observing changes. (Sources/SwiftEnvironment/Environment/GlobalValues.swift)
  • Refactored GlobalEnvironment Property Wrapper: Updated the GlobalEnvironment property wrapper to use GlobalValues instead of EnvironmentValues. This change simplifies value resolution and observation logic. (Sources/SwiftEnvironment/Environment/GlobalEnvironment.swift) [1] [2]

Documentation Updates:

  • Updated README.md: Revised the documentation to reflect the new GlobalValues structure and its usage. Added sections on defining, accessing, and setting global values, along with advanced options like transient values and weak references. (README.md) [1] [2]

Code Cleanup and Removal:

  • Removed Deprecated Files: Deleted files related to the old SwiftEnvironmentValues implementation (SwiftEnvironmentValues.swift, EnvironmentSource.swift, SwiftUIEnvironment+Extensions.swift) to streamline the codebase. (Sources/SwiftEnvironment/GlobalEnvironment/SwiftEnvironmentValues.swift) [1] (Sources/SwiftEnvironment/GlobalEnvironment/EnvironmentSource.swift) [2] (Sources/SwiftEnvironment/Extensions/SwiftUIEnvironment+Extensions.swift) [3]

Dependency Updates:

  • Added swift-syntax Dependency: Updated Package.swift to include the swift-syntax package for macro support, enabling the new @GlobalEntry macro functionality. (Package.swift) [1] [2]

@hainayanda hainayanda requested a review from Copilot May 31, 2025 05:34
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 performs a comprehensive rewrite of the global environment management system in SwiftEnvironment by replacing the old SwiftUI-based EnvironmentValues with a new GlobalValues structure and updating the related API, macros, tests, and documentation. Key changes include:

  • Replacing EnvironmentValues references with GlobalValues in tests, property wrappers, and extensions.
  • Introducing the @globalentry macro and its compiler plugin for defining global entries.
  • Cleaning up deprecated files and updating the README to reflect new usage and dependency versions.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Tests/SwiftEnvironmentTests/IntegrationTests.swift Updated tests to utilize GlobalValues instead of EnvironmentValues.
Tests/SwiftEnvironmentTests/DummyDependency.swift Shifted from EnvironmentValues to GlobalValues for dummy dependency setup.
Sources/SwiftEnvironmentMacro/* Added new macro plugin and associated error/expansion logic.
Sources/SwiftEnvironment/GlobalValues.swift Introduced GlobalValues structure to manage global state.
Sources/SwiftEnvironment/Environment/GlobalEnvironment.swift Updated property wrapper to work with GlobalValues.
README.md Updated documentation to reflect API changes and new installation steps.
Package.swift Added swift-syntax dependency and updated dependency versions.
Comments suppressed due to low confidence (1)

README.md:68

  • The reference 'GlobalValue.myValue' appears to be a naming inconsistency. It likely should be 'GlobalValues.myValue' to match the new API conventions.
let value = GlobalValue.myValue

@hainayanda hainayanda merged commit 728ebaa into main May 31, 2025
3 checks passed
@hainayanda hainayanda deleted the feature/distinct-global-values branch May 31, 2025 05:46
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
0