-
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathSceneGraphNode.swift
More file actions
54 lines (51 loc) · 1.95 KB
/
SceneGraphNode.swift
File metadata and controls
54 lines (51 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/// A persistent representation of a scene that maintains its state even when
/// the scene itself gets recomputed.
///
/// This is required to store view graphs, widget handles, etc.
///
/// Treat scenes as basic data structures that simply encode the structure of
/// the app; the actual rendering and logic is handled by the node.
@MainActor
public protocol SceneGraphNode: AnyObject {
/// The type of scene managed by this node.
associatedtype NodeScene: Scene where NodeScene.Node == Self
/// Creates a node from a corresponding scene.
///
/// Should perform initial setup of any widgets required to display the
/// scene (although ``SceneGraphNode/update(_:backend:environment:)`` is
/// guaranteed to be called immediately after initialization).
///
/// - Parameters:
/// - scene: The scene to create the node from.
/// - backend: The app's backend.
/// - environment: The current root-level environment.
init<Backend: AppBackend>(
from scene: NodeScene,
backend: Backend,
environment: EnvironmentValues
)
/// Updates the scene's node without committing anything to screen or
/// propagating the update to child views.
///
/// - Parameters:
/// - newScene: The recomputed scene if the update is due to it being
/// recomputed.
/// - environment: The current root-level environment.
/// - Returns: The result of updating the scene node.
func updateNode(
_ newScene: NodeScene?,
environment: EnvironmentValues
) -> SceneNodeUpdateResult
/// Updates the scene.
///
/// Unlike views (which have state), scenes are only ever updated when
/// they're recomputed or immediately after they're created.
///
/// - Parameters:
/// - backend: The app's backend.
/// - environment: The current environment.
func update<Backend: AppBackend>(
backend: Backend,
environment: EnvironmentValues
)
}