xilem icon indicating copy to clipboard operation
xilem copied to clipboard

xilem_web: Factor element state out of the view context via associated type bounds

Open Philipp-M opened this issue 10 months ago • 5 comments

Based on this comment and my rather unsatisfying experiments in https://github.com/Philipp-M/xilem/commit/039888a127723c687143b8a7eea02e0731ea6eac

I have removed the need for intermediate state in the view context via a trait ElementProps (and in the future likely traits for other DOM interfaces). This requires a new Rust feature associated_type_bounds which is not yet in stable Rust, but will be in 1.79 (it unfortunately just missed the window for 1.78). So this will likely stay a draft PR until then as there's no hurry, and the workaround for it is not worth it in the meantime I think, but I wanted to at least make it public (to avoid possibly merge conflicts etc.).

This PR should be seen as a base for future typed features of DOM elements (such as seen in the video example), to avoid putting all the state for all kinds of elements in the context (which will likely blow up WASM blob size).

Philipp-M avatar Apr 11 '24 08:04 Philipp-M

Hey this looks cool! Are you planning to take it out of draft at some point?

richard-uk1 avatar Apr 20 '24 15:04 richard-uk1

As described, I think it makes sense to wait until Rust 1.79 (where the following feature will be stabilized) since this currently requires unstable Rust:

#![feature(associated_type_bounds)]

Not sure whether it makes sense to make an exception here (as xilem_web is still kinda experimental, and it may otherwise block progress in xilem_web?)

Philipp-M avatar Apr 21 '24 14:04 Philipp-M

I think we should wait for stable Rust. It's not too far away.

xStrom avatar Apr 21 '24 18:04 xStrom

Yeah - using nightly features makes testing harder, and requires decisions about which nightly to use.

I could maybe see requiring beta, where this would be "stable" in about two weeks. That's what I did for Android Trace, for example.

DJMcNab avatar Apr 22 '24 08:04 DJMcNab

Just that there's no misunderstanding. The required feature won't be in next stable Rust (1.78) but the version after that that is planned for release at 13th June. See here

Philipp-M avatar Apr 22 '24 10:04 Philipp-M

I'm closing this, as I'm currently rewriting xilem_web and found a better/cleaner solution for this.

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