Skip to content

Commit

Permalink
Updates to fix change closure
Browse files Browse the repository at this point in the history
  • Loading branch information
simlay committed Apr 12, 2024
1 parent 5096042 commit a31e66c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,15 @@ public class LiveViewCoordinator<R: RootRegistry>: ObservableObject {

private func handleJoinPayload(renderedPayload: Payload) {
// todo: what should happen if decoding or parsing fails?
//self.rendered = try! Root(from: FragmentDecoder(data: renderedPayload))
//self.document = try! LiveViewNativeCore.Document.parse(rendered.buildString())
self.document = try! LiveViewNativeCore.Document.parseFragmentJson(payload: renderedPayload)
self.document?.on(.changed) { [unowned self] doc, nodeRef in
switch doc[nodeRef].data() {
self.document?.on(.changed) { [unowned self] doc, nodeRef, nodeData, parent in
switch nodeData {
case .root:
// when the root changes, update the `NavStackEntry` itself.
self.objectWillChange.send()
case .leaf:
// text nodes don't have their own views, changes to them need to be handled by the parent Text view
if let parent = doc.getParent(nodeRef) {
if let parent = parent {
self.elementChanged(nodeRef).send()
} else {
self.elementChanged(nodeRef).send()
Expand Down

0 comments on commit a31e66c

Please sign in to comment.