Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ra1028 committed Apr 17, 2024
1 parent 0763ad5 commit 2a11f4f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ The attributes allow control over how the atoms essentially work, for example, c

#### [Scoped](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/scoped)

`Scoped` preserves the atom state in the nearest scope in the ancestor of where it is used and prevent it from being shared outside of the scope.
`Scoped` preserves the atom state in the scope nearest to the ancestor of where it is used and prevents it from being shared out of scope.

<details><summary><code>📖 Example</code></summary>

Expand Down Expand Up @@ -1250,7 +1250,7 @@ struct NewsView: View {
#### Scoped Atoms

This library is designed with the shared state as a single source of truth first principle, but also the state can be scoped depending on the intended use.
Scoped atoms preserve their state in the nearest [AtomScope](#atomscope) in the ancestor of the view in which the atom is used, and they are not shared outside the scope. `Scoped` is the attribute for that feature.
Scoped atoms preserves the atom state in the [AtomScope](#atomscope) nearest to the ancestor of where it is used and prevents it from being shared out of scope. `Scoped` is the attribute for that feature.

```swift
struct TextInputAtom: StateAtom, Scoped Hashable {
Expand Down Expand Up @@ -1302,8 +1302,8 @@ AtomScope(id: TextScopeID()) {
}
```

This is also useful when multiple identical screens are stacked and each has isolated states such as user inputs.
Note that other atoms that depend on the scoped atom will be in a shared state and must be given `Scoped` attribute as well in order to scope them as well.
This is also useful when multiple identical screens are stacked and each screen needs isolated states such as user inputs.
Note that other atoms that depend on scoped atoms will be in a shared state and must be given `Scoped` attribute as well in order to scope them as well.

#### Override Atoms

Expand Down
4 changes: 2 additions & 2 deletions Sources/Atoms/Attribute/Scoped.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// An attribute protocol to preserve the atom state in the nearest scope in the ancestor of
/// where it is used and prevent it from being shared outside of the scope.
/// An attribute protocol to preserve the atom state in the scope nearest to the ancestor
/// of where it is used and prevents it from being shared out of scope.
///
/// If multiple scopes are nested, you can define an arbitrary `scopeID` to ensure that
/// values are stored in a particular scope.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Atoms/Context/AtomCurrentContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct AtomCurrentContext<Coordinator>: AtomContext {
/// and assigns a new value for the atom.
/// When you assign a new value, it immediately notifies downstream atoms and views.
///
/// - SeeAlso: ``AtomViewContext/subscript(_:)``
/// - SeeAlso: ``AtomContext/subscript(_:)``
///
/// ```swift
/// let context = ...
Expand Down
2 changes: 1 addition & 1 deletion Sources/Atoms/Context/AtomTestContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public struct AtomTestContext: AtomWatchableContext {
/// and assigns a new value for the atom.
/// When you assign a new value, it immediately notifies downstream atoms and views.
///
/// - SeeAlso: ``AtomTestContext/subscript(_:)``
/// - SeeAlso: ``AtomContext/subscript(_:)``
///
/// ```swift
/// let context = AtomTestContext()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Atoms/Context/AtomTransactionContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public struct AtomTransactionContext<Coordinator>: AtomWatchableContext {
/// and assigns a new value for the atom.
/// When you assign a new value, it immediately notifies downstream atoms and views.
///
/// - SeeAlso: ``AtomTransactionContext/subscript(_:)``
/// - SeeAlso: ``AtomContext/subscript(_:)``
///
/// ```swift
/// let context = ...
Expand Down
2 changes: 1 addition & 1 deletion Sources/Atoms/Context/AtomViewContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public struct AtomViewContext: AtomWatchableContext {
/// and assigns a new value for the atom.
/// When you assign a new value, it immediately notifies downstream atoms and views.
///
/// - SeeAlso: ``AtomViewContext/subscript(_:)``
/// - SeeAlso: ``AtomContext/subscript(_:)``
///
/// ```swift
/// let context = ...
Expand Down

0 comments on commit 2a11f4f

Please sign in to comment.