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
feat: add experimental memo decorator for JS-level component and function memoization (#6192)
* feat: add experimental memo decorator for JS-level component and function memoization
Introduce rx.experimental.memo (rx._x.memo) that allows memoizing
components and plain functions at the JavaScript level. Supports
component memos with typed props (including children and rest props
via RestProp), and function memos that emit raw JS. Updates the
compiler pipeline to handle both memo kinds alongside existing
CustomComponent memos, and refactors signature rendering to use
DestructuredArg.
* fix: prevent memo name collisions and compile-time mutation of stored components
Add registry helpers that detect duplicate exported names across memo
kinds and raise on collision. Deepcopy the component before applying
styles during compilation so the stored definition stays clean. Simplify
the function wrappers .call to alias the wrapper itself.
* test: clear old memos when testing.
* test: cleanup
* pyi: update hashes
* fix: camelCase rest-prop keys in memo function bindings and clean up memo internals
Convert remaining_props keys to camelCase in _bind_function_runtime_args
so rest props (e.g. class_name → className) match the component memo
behavior. Also make MemoParam kw_only, return a tuple from get_props
instead of a dict, and remove unnecessary monkeypatch boilerplate from
the integration test fixture.
* refactor: replace memo wrapper closures with proper callable classes
Replace _create_function_wrapper and _create_component_wrapper closures
with _ExperimentalMemoFunctionWrapper and _ExperimentalMemoComponentWrapper
classes, eliminating object.__setattr__ hacks for call/partial/_as_var
in favor of real methods.
* updated hashes
* fix: accept Var[Component] return from component-returning memos
Extract _normalize_component_return to wrap Var[Component] values in
Bare.create, allowing memos that return rx.cond or other component-typed
vars to be registered as component memos. Add a cond overload for
(Any, Var[Component], Var[Component]) -> Component.
* refactor: create per-memo component subclasses with tag set at class level
Replace instance-level self.tag assignment with cached dynamically
created ExperimentalMemoComponent subclasses via
_get_experimental_memo_component_class, so the tag is a class-level
attribute rather than set in _post_init.
---------
Co-authored-by: Masen Furer <m_github@0x26.net>
0 commit comments