framesurge / perseus

A state-driven web development framework for Rust with full support for server-side rendering and static generation.
https://framesurge.sh/perseus/en-US
MIT License
2.15k stars 89 forks source link

State amalgamation with different types #307

Open smessmer opened 1 year ago

smessmer commented 1 year ago

This issue is requesting an enhancement to Perseus. Details of the scope will be available in issue labels. The user described the problem related to this request as follows:

State amalgamation with different types

The user described the issue as follows:

State amalgamation currently uses the same state type for build type state, request time state, and amalgamated state. This makes using it a bit awkward since likely have to use some kind of enum with variants for the different kinds of states in it. It would be more convenient if you could just specify separate types for BuildTimeState, RequestTimeState and an fn amalgamate(BuildTimeState, RequestTimeState) -> AmalgamatedState function.

  • The author is willing to attempt an implementation: false
Tribble internal data dHJpYmJsZS1yZXBvcnRlZCxDLWVuaGFuY2VtZW50
arctic-hen7 commented 1 year ago

This shouldn't be impossible, because Perseus only cares about state types at the very last second when it parses them to your custom functions, and, given enums aren't supported by the reactive state macro yet, I think this is perfectly reasonable. I'll get on this soon, but I'd be happy to accept a PR in the meantime!