Skip to main content

Store Transformations

Now, let's take a look at how Store is optimized. In Geajs, the compiler performs static analysis based on the way the Store is written and the file structure, and automatically applies transformations that minimize runtime overhead as much as possible.

CategoryLean transformationCompiledStore
RequirementsWhen the conditions are met in a “1 File, 1 Store” configuration1. For example, when there are multiple Stores in a single file, etc.
Runtime BaseCompiledLeanStoreCompiledStore
Optimization LevelMaximum (Object/Closure)Standard (Class inheritance)
Fallback RiskLow (Isolated)High (All-or-nothing)
  1. Lean Transformation Lean Transformation is an optimization process that completely removes the class structure (class ... extends Store) and rewrites it as lightweight JavaScript objects and closures.

Key Features and Benefits​

  • Reduces the overhead of class inheritance: The cost of instance creation and prototype chain lookups is reduced to zero.

  • Maximizes memory efficiency: Since it does not carry unnecessary metadata, it enables lightweight state management.

  • Fast reactive tracking: Handles state change notifications with a minimal number of function calls.

  1. Static Analysis and Safety Controls for Array Operations When state changes occur within a Store and involve destructive array methods (such as splice, pop, shift, unshift, sort, and reverse) or direct modifications to the length property, the compiler automatically inserts optimal monitoring logic to prevent reactive tracking inconsistencies.