-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Establish App lifecycle as the only way to start rendering #224
Comments
Yeah, this makes sense to me. |
It depends on if we want people to be able to incrementally adopt Tokamak. I think it’s perfectly fine to say that you have to write the entire app in Tokamak (or at least the root of the app), but it should be an explicit thing we document. |
I think you would still be able to do that, but you’d have to define the tokamak part of your site with App at the root. |
@j-f1 Excellent point, and I'm not sure I'm ready to commit to that yet myself, unless there's a strong pressure to do that. |
Removing the |
Scratch that custom scene suggestion, I probably would prefer something like: extension App {
func _render(in: JSObjectRef) {
// ...
}
} There you'd call This would need to set up multiple instances of |
I do think the custom scene type might be worth exploring since there aren’t any other uses for multiple scenes atm |
I'm not sure how you'd schedule at what moment those scenes are displayed. Say you have a big React app with hundreds of components and you want to to rewrite it incrementally, but you'd probably proceed in different branches of the big component tree, even if sequentially. It would be hard to connect those different branches with scenes, especially if those different branches are not displayed at the same time. Maybe those component branches are on different "pages" and these "pages" are displayed separately. I'm not sure how to map that well to the scenes API, the |
That makes sense. |
Maybe it could work with struct ProfileScene: Scene {
var body: some Scene {
DOMScene(node: { ... }) {
WindowGroup { ... }
}
}
} struct SearchScene: Scene {
var body: some Scene {
DOMScene(node: { ... }) {
WindowGroup { ... }
}
}
} struct Reddit: App {
var body: some Scene {
ProfileScene()
SearchScene()
}
} Where struct DOMScene<Content: Scene>: Scene {
let body: Content
let nodeQuery: () -> JSObjectRef?
init(node nodeQuery: () -> JSObjectRef?, @SceneBuilder body: Content) { ... }
init(id: String, @SceneBuilder body: Content) { ... }
} Then when |
Removes the `View`-based initializer of `DOMRenderer` which no longer leaves any `public` initializers on it, means we can make it fully internal. `DOMNode` is now internal too, which is great as it was an implementation detail anyway. Corollary, `DefaultApp` is no longer needed. `Target` was cleaned up is it doesn't need to hold `App` or `Scene` values, now it's just a simple protocol. I've updated `README.md` to show usage of the `App` protocol in the basic example. Closes #224.
The reasoning here is that the only way to start rendering should be through creating an
App
type and callingmain()
on it. This would allow us to remove theView
-basedDOMRenderer
initializer and also thread the type ofApp
throughDOMRenderer
andStackReconciler
through generics without erasing it with_AnyApp
. Then potentially we could remove_AnyApp
and the indirection it requires altogether._AnyApp
is not present in the upstream API anyway 🤔What do you think @carson-katri @j-f1?
The text was updated successfully, but these errors were encountered: