refactor(core): remove Params and replace with strings#2191
Merged
Conversation
wusyong
reviewed
Jul 10, 2021
Member
|
Thanks! I think this will really improve a lot on code readability and still keep the runtime generic configurable. |
wusyong
reviewed
Jul 11, 2021
wusyong
reviewed
Jul 11, 2021
wusyong
approved these changes
Jul 14, 2021
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.
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
The PR fulfills these requirements:
fix: #xxx[,#xxx], where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
See #2179 for prior work that sparked this PR. I've added most of my TODO notes to the change log instead of throughout the code because the diff is large enough to lose track of them easily.
The conversation in discord spanned a couple hours and a few more smaller discussion after that, so I will try to sum up the motivation behind the breaking change in bullet points:
Paramswas added during a large refactor multiple months ago, and allowed us to put user-defined types throughout the codebase (bonus: statically dispatched).Argsas a private markerParamstype to simplify the generic parameters in most of the internal code but it needed a lot of generics on it. This was of course particularly painful where we had to useArgsinstead ofParamssuch as the builder and internal window manager.Params(ofc it was just released during beta) and instead struggled to comprehend the now mentally complex Rust API (particularly to people learning or new to Rust) in places. The not many people measurement is vague, but based on hardly any questions in the discord were about using it and instead about trying to use strings in the API whereParamsmade things more complex type-wise. Also in a cursory GitHub search of projects using Tauri beta the first 4-5 pages had no projects where non-default (String) types were used.Params, the types effectively always had to represent a string in some form (DisplayorSerialize). Storing those types directly with static dispatch in internal implementation is not really necessary as they had to be turned into a string at some point anyways.tauridoesn't require being injected into the internals for all current cases. It can instead live in another crate (TBD) with a less stable API as we figure out the most ergonomic way to allow complex compile time type checking without ruining the ease of development without it.So this PR is the result of those bullet points. Because another crate can effectively wrap
tauriwith a stronger API, the complexity introduced intauriitself for it is unnecessary and should be shed beforev1. The more strongly typed API can be created separately at a later time.This is a breaking change. It completely removes
Paramsand replaces all the associated types previously on it with either strings (Event,Label,MenuId,SystemTrayMenuId) or trait objects (Assets). Items that previously tookParamsnow take onlyRuntime. It also removes traits that served solely to help manage those string types, such asTag,TagRef, andMenuId.I was (hopefully) consistent about putting
impl Into<String>in places where we are accepting an owned string in a public api, let me know if I missed any. We might also want to change all the public API that accepts&strtoimpl AsRef<str>but I didn't do that as I went.We should really flesh out the changelog on this change since this is a decently sized breaking change.
Marked as draft until we finish off the todos and the change file.