-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove all redundant macros! 🎉 #238
Merged
Merged
Conversation
This file contains 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
No tests will pass right now!
Also fixed a few typos that had accumulated recently, mostly in the state platform docs.
…s-state I believe this is necessary to make a certain associated type guarantee compile. Tests are failing on CI, but I'm willing to ignore that for now (pretty sure it's a GHA bug).
The `#[template]` macro is now only required for templates that generate state, and only temporarily I think.
This is the simplest macro in history, and is now used everywhere to clearly mark functions that are engine-side-only. This is a huge improvement over the opacity of `#[build_state]` and co., which did this implicitly. Also, this macro is simple enough to avoid easily if a user wants to.
This removes macros from there too, and this all actually compiles now!
Previously, it was just deprecated.
This was referenced Nov 25, 2022
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.
This PR removes (nearly) all macros from Perseus by integrating macro code into closure wrapping in
Template
. Templates that take no state, or unreactive state, can now be used as naked functions. Templates using reactive state presently still have to use#[template]
, although this is a temporary restriction that will be removed either in this PR or in a future one coming very soon.The
#[perseus::main]
macro has been left around, since it serves a very useful function, and cannot be removed without substantial ergonomic compromises, and a new macro,#[engine_only_fn]
has been added, which does exactly what it says on the tin: rewrites the function it annotates to make it do nothing on the browser-side, leaving it as-is on the engine-side. This functionality is trivially simple, and could be easily done manually if one wants to avoid all macros. It has been left around so that functions likeget_build_state()
, etc. can be marked very clearly as only existing on the engine-side, circumventing entirely JS' problems of function coloring (where it isn't clear which 'side' a function can be used on). This target-gating has always been implicit in Perseus, and now it is clear as day.Absolutely zero ergonomic compromises in this PR have been made: state generating functions still return an arbitrary state type, and templates take the reactive version in. The only difference is that there are no macros needed!
This PR also includes support for helper build state, to close #221 by allowing the build paths function to produce arbitrary state that can be taken in by build state, request state, state amalgamation, etc. If you don't want to use it, you can just specify
().into()
as your helper type.This includes the refactoring of build paths to return
BuildPaths
, which has a field forpaths
and a fieldextra
for the new helper state, and other functions that took a path and locale have been similarly refactored to now takeStateGeneratorInfo { path, locale, extra }
.As I'm sure you can imagine, this PR contains a very large number of breaking changes! I am positive however that this will mark a major step forward in the ergonomics of using Perseus' state platform (especially once
#[template]
is gone for good, which is only pending working out a tough type inference problem internally).