You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The unused in-memory DOM representation more than doubles the memory usage required to service a request and complicates the implementation to having a seperate buffer per element. I think a lot can be gained my dropping the in memory DOM representation: a single ActionView buffer can be passed from parent to child, lowering memory usage and allow us to use streaming responses.
This is essentially how Phlex works and it’s really fast because you don’t need to allocate an object for each element. The generated HTML tag methods are essentially:
Yes, see activeadmin-rails@312ee73?diff=split&w=1 for my less elegant but working replacement of Element#to_s. I think it would be interesting to replace Arbre or Arbo with Phlex in ActiveAdmin but I am not familiar with how Phlex interoperates with ActionView and Rails helpers (especially form builders, though replacing Formtastic would also be good). Could it be done in a way that is (mostly) backward compatible or has a simple migration path?
Some helpers such as form builder helpers need some extra managing to maintain compatibility. Helpers like form_with yield a FormBuilder, which has output helpers and value helpers on it, so Phlex decorates the form builder.
Activity
joeldrapper commentedon Jul 2, 2024
This is essentially how Phlex works and it’s really fast because you don’t need to allocate an object for each element. The generated HTML tag methods are essentially:
varyonic commentedon Jul 2, 2024
Yes, see activeadmin-rails@312ee73?diff=split&w=1 for my less elegant but working replacement of Element#to_s. I think it would be interesting to replace Arbre or Arbo with Phlex in ActiveAdmin but I am not familiar with how Phlex interoperates with ActionView and Rails helpers (especially form builders, though replacing Formtastic would also be good). Could it be done in a way that is (mostly) backward compatible or has a simple migration path?
joeldrapper commentedon Jul 2, 2024
I expect so. Phlex Rails defines wrappers for each ActionView helper because it needs to behave in different ways depending on the kind of helper.
There are essentially two kinds of helpers:
For example, here the
link_tohelper is an output helper, and thedashboard_pathhelper is a value helper.We don’t need to do anything like
All the helpers are defined here. https://github.com/phlex-ruby/phlex-rails/tree/main/lib/phlex/rails/helpers
Some helpers such as form builder helpers need some extra managing to maintain compatibility. Helpers like
form_withyield aFormBuilder, which has output helpers and value helpers on it, so Phlex decorates the form builder.