reactive-proxy
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.2 • Public • Published

    Reactive Proxy Implementation (ES6+)

    Example

    import ReactiveProxy from 'reactive-proxy';
    
    const source = {a: { b: { c: { d: 5 } } } };
    
    const proxy = new ReactiveProxy(source, {
      get(target, prop, receiver, propPath) {
        console.log("get prop:", propPath);
        return Reflect.get(target, prop, receiver);
      },
      set(target, p, value, r, propPath, reactiveWrapper) {
        console.log("set prop:", propPath);
        return Reflect.set(
          target, 
          p, 
          reactiveWrapper(value),  // Wrap to Reactive Proxy Object
          r
        );
      }
    });
    
    let a = proxy.a.b.c.d;
    // Console Output: get prop: ["a", "b", "c", "d"]
    
    proxy.b = {};
    // Console Output: set prop: ["b"]
    
    console.log(proxy.b) // ReactiveChild {}
    
    proxy.b.b
    // Console Output: get prop: ["b", "b"]

    Keywords

    none

    Install

    npm i reactive-proxy

    DownloadsWeekly Downloads

    2

    Version

    0.1.2

    License

    MIT

    Unpacked Size

    7.63 kB

    Total Files

    4

    Last publish

    Collaborators

    • _hydrogen