kettanaito/react-advanced-form

Handle observables memory-wise

Opened this issue · 1 comments

What:

  • Need to ensure duplicate observables are not registered for the same purpose
  • Need to flush observable instances that are no longer relevant to the current state of a form
  • (Optional) Optimize existing reactive transformation chains to ensure top performance

Why:

To prevent memory leaks due to a bunch of observables established.

How:

  • Store the established observables in a Map, associated with the reason of observation and keyPath of the issuer. Re-occuring prompts to create an observer for the same reason and the same issuer can be looked up in the storage, and prevented

It may be useful to keep the records of created observables in the form's state. This way whenever a field is registered, and prompts to create an observable, it can look up itself (based on fieldPath) in the form's state, to see if such observable already exists.

This needs to be aligned with the kinds of observables established (rules observer, props observer).