Skip to content

Commit 7a263b0

Browse files
authored
rename _RenderContext to _TransactionContext (#36)
1 parent 4333150 commit 7a263b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+359
-383
lines changed

Sources/ElementaryDOM/Animation/View+Animation.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ struct _TransactionModifierView<Wrapped: View, Value: Equatable>: View {
1414
public static func _makeNode(
1515
_ view: consuming Self,
1616
context: borrowing _ViewContext,
17-
reconciler: inout _RenderContext
17+
tx: inout _TransactionContext
1818
) -> _MountedNode {
19-
let node = Wrapped._makeNode(view.view, context: context, reconciler: &reconciler)
19+
let node = Wrapped._makeNode(view.view, context: context, tx: &tx)
2020
return .init(state: .init(value: view.value), child: node)
2121
}
2222

2323
public static func _patchNode(
2424
_ view: consuming Self,
2525
node: _MountedNode,
26-
reconciler: inout _RenderContext
26+
tx: inout _TransactionContext
2727
) {
2828
if node.state.value != view.value {
2929
node.state.value = view.value
30-
view.transactionModifier(&reconciler.transaction)
30+
view.transactionModifier(&tx.transaction)
3131
}
3232

33-
Wrapped._patchNode(view.view, node: node.child, reconciler: &reconciler)
33+
Wrapped._patchNode(view.view, node: node.child, tx: &tx)
3434
}
3535
}
3636

Sources/ElementaryDOM/Data/Environment/View+Envionment.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,34 @@ public struct _EnvironmentView<V, Wrapped: View>: View {
3939
public static func _makeNode(
4040
_ view: consuming Self,
4141
context: borrowing _ViewContext,
42-
reconciler: inout _RenderContext
42+
tx: inout _TransactionContext
4343
) -> _MountedNode {
4444
var context = copy context
4545
let box = EnvironmentValues._Box<V>(view.value)
4646
context.environment.boxes[view.key.propertyID] = box
4747

48-
return .init(state: box, child: Wrapped._makeNode(view.wrapped, context: context, reconciler: &reconciler))
48+
return .init(state: box, child: Wrapped._makeNode(view.wrapped, context: context, tx: &tx))
4949
}
5050

5151
public static func _patchNode(
5252
_ view: consuming Self,
5353
node: _MountedNode,
54-
reconciler: inout _RenderContext
54+
tx: inout _TransactionContext
5555
) {
5656
// IMPORTANT: _value does not cause access tracking!
5757
if view.isEqual?(node.state._value, view.value) ?? true {
5858
node.state._value = view.value
5959
} else {
60-
// NOTE: a bit of a hack to allow dependent functions to run in the same reconciler run
61-
reconciler.scheduler.withAmbientRenderContext(
62-
&reconciler,
60+
// TODO: rework this to explicit dependencies
61+
// NOTE: a bit of a hack to allow dependent functions to run in the same transaction run
62+
tx.scheduler.withAmbientTransactionContext(
63+
&tx,
6364
{
6465
node.state.value = view.value
6566
}
6667
)
6768
}
6869

69-
Wrapped._patchNode(view.wrapped, node: node.child, reconciler: &reconciler)
70+
Wrapped._patchNode(view.wrapped, node: node.child, tx: &tx)
7071
}
7172
}

Sources/ElementaryDOM/Data/Lifecycle/View+LifecycleEvents.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ struct _LifecycleEventView<Wrapped: View>: View {
6262
static func _makeNode(
6363
_ view: consuming Self,
6464
context: borrowing _ViewContext,
65-
reconciler: inout _RenderContext
65+
tx: inout _TransactionContext
6666
) -> _MountedNode {
67-
let state = LifecycleState(hook: view.listener, scheduler: reconciler.scheduler)
68-
let child = Wrapped._makeNode(view.wrapped, context: context, reconciler: &reconciler)
67+
let state = LifecycleState(hook: view.listener, scheduler: tx.scheduler)
68+
let child = Wrapped._makeNode(view.wrapped, context: context, tx: &tx)
6969

7070
let node = _StatefulNode(state: state, child: child)
7171
return node
@@ -74,7 +74,7 @@ struct _LifecycleEventView<Wrapped: View>: View {
7474
static func _patchNode(
7575
_ view: consuming Self,
7676
node: _MountedNode,
77-
reconciler: inout _RenderContext
77+
tx: inout _TransactionContext
7878
) {
7979
switch view.listener {
8080
case .onUnmount(let callback):
@@ -84,6 +84,6 @@ struct _LifecycleEventView<Wrapped: View>: View {
8484
break
8585
}
8686

87-
Wrapped._patchNode(view.wrapped, node: node.child, reconciler: &reconciler)
87+
Wrapped._patchNode(view.wrapped, node: node.child, tx: &tx)
8888
}
8989
}

Sources/ElementaryDOM/Data/Lifecycle/View+OnChange.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ struct _OnChangeView<Wrapped: View, Value: Equatable>: View {
5454
static func _makeNode(
5555
_ view: consuming Self,
5656
context: borrowing _ViewContext,
57-
reconciler: inout _RenderContext
57+
tx: inout _TransactionContext
5858
) -> _MountedNode {
5959
let state = State(value: view.value, action: view.action)
60-
let child = Wrapped._makeNode(view.wrapped, context: context, reconciler: &reconciler)
60+
let child = Wrapped._makeNode(view.wrapped, context: context, tx: &tx)
6161

6262
if view.initial {
6363
let initialValue = view.value
6464
let action = view.action
65-
reconciler.scheduler.afterReconcile {
65+
tx.scheduler.afterReconcile {
6666
action(initialValue, initialValue)
6767
}
6868
}
@@ -73,7 +73,7 @@ struct _OnChangeView<Wrapped: View, Value: Equatable>: View {
7373
static func _patchNode(
7474
_ view: consuming Self,
7575
node: _MountedNode,
76-
reconciler: inout _RenderContext
76+
tx: inout _TransactionContext
7777
) {
7878
node.state.action = view.action
7979

@@ -83,11 +83,11 @@ struct _OnChangeView<Wrapped: View, Value: Equatable>: View {
8383
node.state.value = newValue
8484

8585
let action = view.action
86-
reconciler.scheduler.afterReconcile {
86+
tx.scheduler.afterReconcile {
8787
action(oldValue, newValue)
8888
}
8989
}
9090

91-
Wrapped._patchNode(view.wrapped, node: node.child, reconciler: &reconciler)
91+
Wrapped._patchNode(view.wrapped, node: node.child, tx: &tx)
9292
}
9393
}

Sources/ElementaryDOM/Data/Lifecycle/_StatefulNode.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ extension _StatefulNode: _Reconcilable {
2626
child.collectChildren(&ops, &context)
2727
}
2828

29-
public func apply(_ op: _ReconcileOp, _ reconciler: inout _RenderContext) {
30-
child.apply(op, &reconciler)
29+
public func apply(_ op: _ReconcileOp, _ tx: inout _TransactionContext) {
30+
child.apply(op, &tx)
3131
}
3232

3333
public func unmount(_ context: inout _CommitContext) {

Sources/ElementaryDOM/FLIP/FLIPLayoutObserver.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ final class FLIPLayoutObserver: DOMLayoutObserver {
1010
self.animateContainerSize = animateContainerSize
1111
}
1212

13-
func willLayoutChildren(parent: DOM.Node, context: inout _RenderContext) {
13+
func willLayoutChildren(parent: DOM.Node, context: inout _TransactionContext) {
1414
guard !context.transaction.shouldSkipFLIP else {
1515
logTrace("skipping FLIP for children of parent \(parent) because transaction should skip FLIP")
1616
return
@@ -23,7 +23,7 @@ final class FLIPLayoutObserver: DOMLayoutObserver {
2323
}
2424
}
2525

26-
func setLeaveStatus(_ node: DOM.Node, isLeaving: Bool, context: inout _RenderContext) {
26+
func setLeaveStatus(_ node: DOM.Node, isLeaving: Bool, context: inout _TransactionContext) {
2727
logTrace("setting leave status for node \(node) to \(isLeaving)")
2828
if isLeaving {
2929
context.scheduler.flip.markAsLeaving(node)

Sources/ElementaryDOM/FLIP/FLIPScheduler.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class FLIPScheduler {
1111
self.dom = dom
1212
}
1313

14-
func scheduleAnimationOf(_ nodes: [DOM.Node], inParent parentNode: DOM.Node, context: inout _RenderContext) {
14+
func scheduleAnimationOf(_ nodes: [DOM.Node], inParent parentNode: DOM.Node, context: inout _TransactionContext) {
1515
if firstWindowScrollOffset == nil {
1616
storeWindowScrollOffset()
1717
}
@@ -31,7 +31,7 @@ final class FLIPScheduler {
3131
}
3232
}
3333

34-
func scheduleAnimationOf(_ node: DOM.Node, context: inout _RenderContext) {
34+
func scheduleAnimationOf(_ node: DOM.Node, context: inout _TransactionContext) {
3535
if firstWindowScrollOffset == nil {
3636
storeWindowScrollOffset()
3737
}

Sources/ElementaryDOM/HTMLViews/ElementModifiers/AnimateChildrenView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct AnimateContainerLayoutView<Wrapped: View>: View {
1010
static func _makeNode(
1111
_ view: consuming Self,
1212
context: borrowing _ViewContext,
13-
reconciler: inout _RenderContext
13+
tx: inout _TransactionContext
1414
) -> _MountedNode {
1515

1616
let observer = FLIPLayoutObserver(
@@ -22,17 +22,17 @@ struct AnimateContainerLayoutView<Wrapped: View>: View {
2222

2323
return _MountedNode(
2424
state: observer,
25-
child: Wrapped._makeNode(view.wrapped, context: context, reconciler: &reconciler)
25+
child: Wrapped._makeNode(view.wrapped, context: context, tx: &tx)
2626
)
2727
}
2828

2929
static func _patchNode(
3030
_ view: consuming Self,
3131
node: _MountedNode,
32-
reconciler: inout _RenderContext
32+
tx: inout _TransactionContext
3333
) {
3434
node.state.update(animateContainerSize: view.animateContainerSize)
35-
Wrapped._patchNode(view.wrapped, node: node.child, reconciler: &reconciler)
35+
Wrapped._patchNode(view.wrapped, node: node.child, tx: &tx)
3636
}
3737
}
3838

Sources/ElementaryDOM/HTMLViews/ElementModifiers/AttributeModifier.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public final class _AttributeModifier: DOMElementModifier, Invalidateable {
1414
return combined
1515
}
1616

17-
init(value: consuming Value, upstream: borrowing DOMElementModifiers, _ context: inout _RenderContext) {
17+
init(value: consuming Value, upstream: borrowing DOMElementModifiers, _ context: inout _TransactionContext) {
1818
self.lastValue = value
1919
self.upstream = upstream[_AttributeModifier.key]
2020
self.upstream?.tracker.addDependency(self)
@@ -27,7 +27,7 @@ public final class _AttributeModifier: DOMElementModifier, Invalidateable {
2727
#endif
2828
}
2929

30-
func updateValue(_ value: consuming Value, _ context: inout _RenderContext) {
30+
func updateValue(_ value: consuming Value, _ context: inout _TransactionContext) {
3131
if value != lastValue {
3232
lastValue = value
3333
tracker.invalidateAll(&context)
@@ -39,7 +39,7 @@ public final class _AttributeModifier: DOMElementModifier, Invalidateable {
3939
return AnyUnmountable(MountedInstance(node, self, &context))
4040
}
4141

42-
func invalidate(_ context: inout _RenderContext) {
42+
func invalidate(_ context: inout _TransactionContext) {
4343
self.tracker.invalidateAll(&context)
4444
}
4545
}
@@ -59,7 +59,7 @@ extension _AttributeModifier {
5959
updateDOMNode(&context)
6060
}
6161

62-
func invalidate(_ context: inout _RenderContext) {
62+
func invalidate(_ context: inout _TransactionContext) {
6363
guard !isDirty else { return }
6464
logTrace("invalidating attribute modifier")
6565
isDirty = true

Sources/ElementaryDOM/HTMLViews/ElementModifiers/BindingModifiers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ final class BindingModifier<Configuration>: DOMElementModifier, Unmountable wher
99
var accessor: DOM.PropertyAccessor?
1010
var isDirty: Bool = false
1111

12-
init(value: consuming Value, upstream: borrowing DOMElementModifiers, _ context: inout _RenderContext) {
12+
init(value: consuming Value, upstream: borrowing DOMElementModifiers, _ context: inout _TransactionContext) {
1313
self.lastValue = value.wrappedValue
1414
self.binding = value
1515
}
1616

17-
func updateValue(_ value: consuming Value, _ context: inout _RenderContext) {
17+
func updateValue(_ value: consuming Value, _ context: inout _TransactionContext) {
1818
self.binding = value
1919

2020
if !Configuration.equals(binding.wrappedValue, lastValue) {
@@ -23,7 +23,7 @@ final class BindingModifier<Configuration>: DOMElementModifier, Unmountable wher
2323
}
2424
}
2525

26-
private func markDirty(_ context: inout _RenderContext) {
26+
private func markDirty(_ context: inout _TransactionContext) {
2727
precondition(mountedNode != nil, "Binding effect can only be marked dirty on a mounted element")
2828
guard !isDirty else { return }
2929
isDirty = true

0 commit comments

Comments
 (0)