Skip to content

Commit 3abffe4

Browse files
authored
Update README (#139)
* Add animation modifier in readme * Fix broken links
1 parent 19e16a2 commit 3abffe4

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

README.md

+38-8
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,37 @@ struct CountDisplayView: View {
694694

695695
</details>
696696

697-
#### [phase](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atom/phase)
697+
#### [animation(_:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atom/animation(_:))
698+
699+
| |Description|
700+
|:--------------|:----------|
701+
|Summary |Animates the view watching the atom when the value updates.|
702+
|Output |`T`|
703+
|Compatible |All atom types.|
704+
|Use Case |Apply animation to a view|
705+
706+
<details><summary><code>📖 Example</code></summary>
707+
708+
```swift
709+
struct TextAtom: ValueAtom, Hashable {
710+
func value(context: Context) -> String {
711+
""
712+
}
713+
}
714+
715+
struct ExampleView: View {
716+
@Watch(TextAtom().animation())
717+
var text
718+
719+
var body: some View {
720+
Text(text)
721+
}
722+
}
723+
```
724+
725+
</details>
726+
727+
#### [TaskAtom/phase](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/taskatom/phase) | [ThrowingTaskAtom/phase](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/throwingtaskatom/phase)
698728

699729
| |Description|
700730
|:--------------|:----------|
@@ -1027,8 +1057,8 @@ Context is a structure for using and interacting with atom values from views or
10271057
|[set(_:for:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomcontext/set(_:for:))|Sets a new value to the atom.|
10281058
|[modify(_:body:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomcontext/modify(_:body:))|Modifies the cached atom value.|
10291059
|[subscript[]](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomcontext/subscript(_:))|Read-write access for applying mutating methods.|
1030-
|[refresh(_:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomcontext/refresh(_:)-1gb3a)|Produce a new value of the atom after waiting until asynchronous operation is complete.|
1031-
|[reset(_:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomcontext/reset(_:))|Reset an atom to the default value or a first output.|
1060+
|[refresh(_:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomcontext/refresh(_:)-7xzm9)|Produce a new value of the atom after waiting until asynchronous operation is complete.|
1061+
|[reset(_:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomcontext/reset(_:)-8u78a)|Reset an atom to the default value or a first output.|
10321062

10331063
Contexts are provided in the following types depending on the environment where they are provided. In addition to the common APIs described above, each context type may have its unique functionalities.
10341064

@@ -1148,7 +1178,7 @@ A context that can simulate any scenarios in which atoms are used from a view or
11481178
|:--|:--|
11491179
|[lookup(_:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/lookup(_:))|Gets an atom value without creating a cache.|
11501180
|[unwatch(_:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/unwatch(_:))|Simulates a scenario in which the atom is no longer watched.|
1151-
|[override(_:with:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/override(_:with:)-40pb3)|Overwrites the output of a specific atom or all atoms of the given type with the fixed value.|
1181+
|[override(_:with:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/override(_:with:)-82t4q)|Overwrites the output of a specific atom or all atoms of the given type with the fixed value.|
11521182
|[waitForUpdate(timeout:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/waitforupdate(timeout:))|Waits until any of the atoms watched through this context have been updated.|
11531183
|[wait(for:timeout:until:)](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/wait(for:timeout:until:))|Waits for the given atom until it will be a certain state.|
11541184
|[onUpdate](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomtestcontext/onupdate)|Sets a closure that notifies there has been an update to one of the atoms.|
@@ -1201,7 +1231,7 @@ class FetchMusicsTests: XCTestCase {
12011231
#### [AtomScope](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atomscope)
12021232

12031233
`AtomScope` allows you to monitor changes or override atoms used in descendant views. Unlike `AtomRoot`, they affect only those in scope.
1204-
See the [Override Atoms](#override-atoms) and [Debugging](#debugging) sections for specific uses.
1234+
See the [Atom Override](#atom-override) and [Debugging](#debugging) sections for specific uses.
12051235

12061236
```swift
12071237
AtomScope {
@@ -1311,7 +1341,7 @@ You can create custom effects that conform to the [`AtomEffect`](https://ra1028.
13111341
|[ReleaseEffect](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/releaseeffect)|Performs an arbitrary action when the atom is released.|
13121342
|[MergedEffect](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/mergedeffect)|Merges multiple atom effects into one.|
13131343

1314-
Atom effects are attached to atoms via the [`Atom.effect(context:)`](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atom/effect(context:)-2kcbd) function.
1344+
Atom effects are attached to atoms via the [`Atom.effect(context:)`](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/atom/effect(context:)-4wm5m) function.
13151345

13161346
```swift
13171347
struct CounterAtom: StateAtom, Hashable {
@@ -1408,7 +1438,7 @@ var body: some {
14081438
}
14091439
```
14101440

1411-
Note that overridden atoms in `AtomScope` automatically be scoped, but other atoms that depend on them will be in a shared state and must be given `Scoped` attribute (See also: [Scoped Atoms](#scoped-atoms)) in order to avoid it from being shared across out of scope.
1441+
Note that overridden atoms in `AtomScope` automatically be scoped, but other atoms that depend on them will be in a shared state and must be given `Scoped` attribute (See also: [Scoped Atom](#scoped-atom)) in order to avoid it from being shared across out of scope.
14121442

14131443
See [Testing](#testing) section for details on dependency injection on unit tests.
14141444

@@ -1627,7 +1657,7 @@ struct TextCopyView: View {
16271657

16281658
#### Dynamically initiate atom families
16291659

1630-
Each atom must have a unique `key` to be uniquely associated with its value. As described in the [Atoms](#atoms) section, it is automatically synthesized by conforming to `Hashable`, but with explicitly specifying a `key` allowing you to pass arbitrary external parameters to the atom. It is commonly used, for example, to retrieve user information associated with a dynamically specified ID from a server.
1660+
Each atom must have a unique `key` to be uniquely associated with its value. As described in the [Atom](#atom) section, it is automatically synthesized by conforming to `Hashable`, but with explicitly specifying a `key` allowing you to pass arbitrary external parameters to the atom. It is commonly used, for example, to retrieve user information associated with a dynamically specified ID from a server.
16311661

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

0 commit comments

Comments
 (0)