fin-hypergrid / core

A canvas-based super high performant grid renderer API
MIT License
897 stars 144 forks source link

Issue #784 Anonymous column calculator bug #786

Closed joneit closed 5 years ago

joneit commented 5 years ago

Resolution

This PR (specifically 1727b44) fixes the bug reported in Issue #784.

This issue was with the column.calculator property overload where the value is a stringified anonymous function (use case 2 below).

calculator setter overloads

The calculator property setter is overloaded for any of the following use cases:

  1. Registered function name
    • Function is dereferenced from the calculators registry
  2. Anonymous stringified function
    • The string is functionified (inflated into an actual function object)
    • The function is registered (if not already in the registry) using the entire function string as the registry key
    • Registering the function normalizes other references to it, i.e., other references to the identical function string will not be individually functionified but will use the function in the registry
  3. Named stringified function
    • The string is functionified
    • The function is registered (if not already in the registry) using the function name as the registry key
    • Registering the function normalizes other references to it, i.e., referenced either with a function string using the same name (the first such function definition is the one that is registered) or simply by name (use case 1 above)
  4. Actual function object
    • The function object is stringified and then treated as use case 2 or 3 above as the case may be.
    • Note that this process strips the function of its execution context, which would be lost anyway when state is persisted (serialized). For a work-around if context is needed, see #785. If you use this work-around, you cannot persist your function with its context and you will need to programmatically recreate it whenever state is reloaded from persistent storage.