xilem
xilem copied to clipboard
Add support for `impl View for Arc/Rc<impl View>`
Now, or later when the examples are improved, this would definitely benefit from a brief example.
Now, or later when the examples are improved, this would definitely benefit from a brief example.
You're right, I could add one here, that shows a use-case for this (it's an alternative to Memoize
)
Good idea to mention the example, I've implemented it via an example for memoization and quite a few views were not yet exported... It also revealed a bomb:
View
needs to be Sync
to support Arc<impl View>
.
I think if we want to store shared views in general in the app state this requirement will come sooner or later (e.g. by supporting a rope of views as a ViewSequence
).
Ok, at least for View::State
, Sync
bounds are not necessary. I've relaxed this via adjustments in the macros.
I have added impl View for Arc<dyn AnyView>
as well (resolves the TODO in the example and makes everything a little bit cleaner).
I've added the super bounds of View
to AnyView
as well, to avoid Box<dyn AnyView + Send + Sync>
Whoops, I was a little bit too eager with deleting old branches...
I think this can be closed - this is included in #310
Yes it can be closed