You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1302,9 +1302,30 @@ AtomRoot {
1302
1302
}
1303
1303
```
1304
1304
1305
-
Calling the [restore()](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/snapshot/restore()) method of the obtained `Snapshot` will roll back to the states and dependency graph at that point in time to see what happened.
1305
+
`@ViewContext` also supports restoring the values of atoms and the dependency graph captured at a point in time in a retrieved snapshot and its dependency graph so that you can investigate what happend.
1306
1306
The debugging technique is called [time travel debugging](https://en.wikipedia.org/wiki/Time_travel_debugging), and the example application [here](Examples/Packages/iOS/Sources/ExampleTimeTravel) demonstrates how it works.
1307
1307
1308
+
```swift
1309
+
@ViewContext
1310
+
var context
1311
+
1312
+
@State
1313
+
var snapshot: Snapshot?
1314
+
1315
+
var body: some View {
1316
+
VStack {
1317
+
Button("Capture") {
1318
+
snapshot = context.snapshot()
1319
+
}
1320
+
Button("Restore") {
1321
+
iflet snapshot {
1322
+
context.restore(snapshot)
1323
+
}
1324
+
}
1325
+
}
1326
+
}
1327
+
```
1328
+
1308
1329
In addition, [graphDescription()](https://ra1028.github.io/swiftui-atom-properties/documentation/atoms/snapshot/graphdescription()) method returns a string, that represents the dependencies graph and where they are used, as a String in [graph description language DOT](https://graphviz.org/doc/info/lang.html).
1309
1330
This can be converted to an image using [Graphviz](https://graphviz.org), a graph visualization tool, to visually analyze information about the state of the application, as shown below.
0 commit comments