Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Objective `Ref` is a useful way of accessing change detection data. However, unlike `Mut`, it doesn't expose a constructor or even a way to go from `Ref<A>` to `Ref<B>`. Such methods could be useful, for example, to 3rd party crates that want to expose change detection information in a clean way. My use case is to map a `Ref<T>` into a `Ref<dyn Reflect>`, and keep change detection info to avoid running expansive routines. ## Solution We add the `new` and `map` methods. Since similar methods exist on `Mut` where they are much more footgunny to use, I judged that it was acceptable to create such methods. ## Workaround Currently, it's not possible to create/project `Ref`s. One can define their own `Ref` and implement `ChangeDetection` on it. One would then use `ChangeTrackers` to populate the custom `Ref` with tick data. --- ## Changelog - Added the `Ref::map` and `Ref::new` methods for more ergonomic `Ref`s --------- Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
- Loading branch information