Skip to content

alternative of Proxy #40

@janjangao

Description

@janjangao

hi, I am trying to use lib proxy-memoize in our website to replace reselect, but our website serves customers, so need be compatible with as many browsers as possible, but proxy-polyfill can't work with this lib, since the polyfill only support a limited scope traps, not include has, deleteProperty and so on.

I also take a look of immerjs to check how it works in non-proxy environment, it use Object.defineProperty instead, so what I think is:

  1. add a condition setUseProxies to disable using Proxy.
  2. have a backup Object.defineProperty implementation, for this scenario, only support limit recording method.
    • record traps get and set
    • getOwnPropertyDescriptor and ownKeys are rarely used and also reasonable if not record them.
    • has and deleteProperty are big problems, only hope the developers notice to don't use them.
      • obj['a'] instead of 'a' in obj
      • const { ...newObj, a } = obj instead of delete obj.a

then I think proxy-memoize can have a widely usage scenarios, hope can as a default selectorCreator be putted in the redux-toolkit one day ^_^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions