feat: 0.7 release (codename futura)#106
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
0.7 release
Codenamed
futura, the 0.7 release ofmogwaiis a very big change.Big conceptual changes
Interlocking traits, crowned by
ViewViews are now structs whose fields are types that implement one or more of an interlocking set of traits -
ViewText,ViewParent,ViewChild,ViewProperties,ViewEventTarget, andViewEventListener.These structs are parameterized with a type variable
V:Viewthat determines the precise type of these fields, given theVpassed in at runtime. It does this with associated types -V::Element,V::Text,V::Node, andV::EventListener. This strategy allows view structs to be written in a platform agnostic way, with platform selection happening at runtime. It also allows "specialization" at runtime using atry_cast_reffunction that casts aV::Elementto a specific type.mogwai0.7 will ship with at least two implementations ofView:WebandSsr.Web'sViewimpl resolves toweb_systypes andSsr'sViewimpl resolves to an internal string representation.Streams are dead
Streams can be cool, but supporting them takes up a bunch of memory due to lots of clones and lots of uses of
wasm_bindgen_futures::spawn_local. 0.7 drops streams in favor of futures. 0.7 is closer to the metal. Don't worry though, the crate still addresses the pain points of UI web dev in a very similar manner, just one that feels less "Reacty".Instead of streams, 0.7 gets closer to the metal by relying on futures and mutability. For example, instead of building up a stream of event messages and matching in a loop, 0.7 relies on stepping through event futures one at a time. The code ends up looking very similar, but there's less cloning and it encourages more idiomatic Rust code and scoping the UI steps to a single future instead of an ongoing stream allows views to be borrowed mutably for short periods, which all contributes to a reduction in memory usage.
RSX updates
The
rsx!macro is completely revamped and focuses on constructing views and capturing the fields necessary for updating the UI. Reactivity is (for the most part) not done in thersx!macro (but there is a bit of that usingProxy, more on that later).ProxyreplacesModel, no magic to see hereProxyis a new type that replacesModel, though it is much simpler and updates are made mutably. Thersx!macro has special support for using proxies to provide a very thin layer of reactivity, but without anyReactstyle magic. View structs must update the value within aProxyexplicitly, but thenProxywill update parts of the view automatically, according to the sites of its use within anrsx!macro.Why are you doing this?
For the most part I love working close to the metal (so to speak) when building web interfaces. Close to the metal in this case means using the browser APIs directly. But of course there are some real pain points with using
web_sysdirectly, especially for creating DOM nodes. So 0.7 makesmogwaias thin a layer over the bare metal while still addressing these specific issues:rsx!macroProxyViewtraitTODO
After merging