Closed ElMassimo closed 4 weeks ago
Hey @ElMassimo thanks for this PR. I'm digging into it now (at long last)!
Just as a heads up, I resolved a merge conflict in the README and committed it to your branch. Hope that's not stepping on your toes.
Made a couple tweak commits and finally got this thing merged! Thanks so much @ElMassimo ! Lovely code that adds some really nice features.
Thanks also to @skryukov for your sharp eyes to catch a few breaking changes that weren't covered by our test suite. I'm going to follow up with a few specs I created locally to cover those things.
I'll get a release out sometime this week in advance of any Inertia v2.0 work.
Released in 3.3.0!
Description 📖
This pull request is a complete refactor of the implementation in order to introduce controller-specific configuration.
inertia_config
A new way for controllers to override the global configuration, and provide dynamic values, such as:
Just like
inertia_share
, configuration is inheritable, and subclasses can override values.In addition, all configuration options can now be procs (before only
version
supported this).Performance 🚀
The implementation of
inertia_share
no longer relies onbefore_action
, improving performance when calculating shared data at runtime, and reducing object allocations.As an additional benefit, we no longer run this code unnecessarily for non-Inertia requests.
Notes ✏️
Each commit is a gradual refactoring, and can be read in isolation (and passes all tests). I'd still suggest using Squash and Merge.
We also
freeze
config and shared data to prevent any mutations, ensuring it's safe for multiple threads to access the configuration from the controller class.