xilem icon indicating copy to clipboard operation
xilem copied to clipboard

Add support for `impl View for Arc/Rc<impl View>`

Open Philipp-M opened this issue 1 year ago • 7 comments

Philipp-M avatar Jan 22 '24 22:01 Philipp-M

Now, or later when the examples are improved, this would definitely benefit from a brief example.

jaredoconnell avatar Jan 23 '24 16:01 jaredoconnell

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)

Philipp-M avatar Jan 23 '24 16:01 Philipp-M

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).

Philipp-M avatar Jan 23 '24 18:01 Philipp-M

Ok, at least for View::State, Sync bounds are not necessary. I've relaxed this via adjustments in the macros.

Philipp-M avatar Jan 24 '24 17:01 Philipp-M

I have added impl View for Arc<dyn AnyView> as well (resolves the TODO in the example and makes everything a little bit cleaner).

Philipp-M avatar Jan 25 '24 16:01 Philipp-M

I've added the super bounds of View to AnyView as well, to avoid Box<dyn AnyView + Send + Sync>

Philipp-M avatar Jan 25 '24 16:01 Philipp-M

Whoops, I was a little bit too eager with deleting old branches...

Philipp-M avatar Mar 13 '24 22:03 Philipp-M

I think this can be closed - this is included in #310

DJMcNab avatar Jun 06 '24 12:06 DJMcNab

Yes it can be closed

Philipp-M avatar Jun 06 '24 13:06 Philipp-M