Skip to content

Commit

Permalink
Fix Observation
Browse files Browse the repository at this point in the history
  • Loading branch information
li3zhen1 committed Feb 21, 2024
1 parent b08c89c commit ae3080e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/Grape/Views/ForceDirectedGraph+Gesture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ extension ForceDirectedGraph {
extension ForceDirectedGraph {
@inlinable
public func onTicked(
perform action: @escaping (KeyFrame) -> Void
perform action: @escaping (UInt) -> Void
) -> Self {
self.model._onTicked = action
return self
Expand Down
2 changes: 1 addition & 1 deletion Sources/Grape/Views/ForceDirectedGraph+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension ForceDirectedGraph: View {
@inlinable
var debugView: some View {
VStack(alignment: .leading, spacing: 8.0) {
Text("Elapsed Time: \(model.currentFrame.rawValue)")
Text("Elapsed Time: \(model.currentFrame)")
Divider()
Text(self.model.changeMessage)
Divider()
Expand Down
8 changes: 4 additions & 4 deletions Sources/Grape/Views/ForceDirectedGraphModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class ForceDirectedGraphModel<Content: GraphContent> {
var _$changeMessage = "N/A"

@usableFromInline
var _$currentFrame: KeyFrame = 0
var _$currentFrame: UInt = 0

@inlinable
var changeMessage: String {
Expand All @@ -93,7 +93,7 @@ public final class ForceDirectedGraphModel<Content: GraphContent> {
}

@inlinable
var currentFrame: KeyFrame {
var currentFrame: UInt {
@storageRestrictions(initializes: _$currentFrame)
init(initialValue) {
_$currentFrame = initialValue
Expand All @@ -119,7 +119,7 @@ public final class ForceDirectedGraphModel<Content: GraphContent> {
var scheduledTimer: Timer? = nil

@usableFromInline
var _onTicked: ((KeyFrame) -> Void)? = nil
var _onTicked: ((UInt) -> Void)? = nil

@usableFromInline
var _onNodeDragChanged: ((NodeID, CGPoint) -> Void)? = nil
Expand Down Expand Up @@ -245,7 +245,7 @@ extension ForceDirectedGraphModel {
func tick() {
withMutation(keyPath: \.currentFrame) {
simulationContext.storage.tick()
currentFrame.advance()
currentFrame += 1
}
_onTicked?(currentFrame)
}
Expand Down

0 comments on commit ae3080e

Please sign in to comment.