diff --git a/Sources/Meta.docc/Tutorials/CreateBackend.md b/Sources/Meta.docc/Tutorials/CreateBackend.md index 80ae064..916d891 100644 --- a/Sources/Meta.docc/Tutorials/CreateBackend.md +++ b/Sources/Meta.docc/Tutorials/CreateBackend.md @@ -373,9 +373,7 @@ For the ``EitherView``, it is again the initializer that has to match a requirem type: Data.Type ) -> ViewStorage where Data: ViewRenderData { let view = TermKit.View() - let storage = ViewStorage(view) - update(storage, data: data, updateProperties: true, type: type) - return storage + return .init(view) } // ... @@ -386,6 +384,7 @@ Normally, you would initialize all your content storages in the container functi In this case, this does not work. If the either view is called via standard `if`/`else` syntax and the condition is `true`, we can access `view1`, but `view2` is empty (the actual view is not known). If `condition` is `false`, `view1` is empty and `view2` is known. Therefore, we have to wait with the initialization process until `condition` changes, which is why this is handled in the `update` function. +Make sure to call the child view's `update` function after constructing a view in the parent view's `update` function. ```swift // ... @@ -406,6 +405,7 @@ Therefore, we have to wait with the initialization process until `condition` cha view = content.pointer as? TermKit.View } else { let content = body.storage(data: data, type: type) + body.update(content, data: data, updateProperties: true, type: type) storage.content[condition.description] = [content] view = content.pointer as? TermKit.View } diff --git a/Sources/Model/User Interface/View/EitherView.swift b/Sources/Model/User Interface/View/EitherView.swift index 571a8e0..e51e2c0 100644 --- a/Sources/Model/User Interface/View/EitherView.swift +++ b/Sources/Model/User Interface/View/EitherView.swift @@ -6,6 +6,8 @@ // /// A view building conditional bodies. +/// +/// Do not forget to call the update function after constructing a new UI. public protocol EitherView: AnyView { /// Initialize the either view.