1.5.3 • Published 1 year ago

listen-proxy v1.5.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Node.js CI version

license

dependancies downloads

stargazers number of forks

  • onExampleAdd: Callback that will be fired when the example property is added.
  • onExampleDelete: Callback that will be fired when the example property is deleted.
  • onExampleChange: Callback that will be fired when the example property is changed.

This package was created because I wanted to test some TS features, credit must be given to Jack Herrington, since a video he did about mapped types was the inspiration for this package, I'll leave the video at the bottom of the readme.

npm install listen-proxy
yarn add listen-proxy
import { createProxy } from "listen-proxy";
const dog = {
  name: 'Rex',
  age: 3,
};

const dogListeners = {
  onNameChange: (value, oldValue, target) => {
    console.log(`The dog's name changed from ${oldValue} to ${value}`, target);
  },
  onAgeDelete: (oldValue) => {
    console.log(`The dog's age was deleted, his age was ${oldValue}`);
  },
  onBreedAdd: (value, target) => {
    console.log(`The dog's breed was added, his breed is ${value} his name is ${target.name}`);
  },
};

const proxyDog = createProxy(dog, dogListeners);


proxyDog.name = 'Rexy'; // The dog's name changed from Rex to Rexy { name: 'Rexy', age: 3 }
delete proxyDog.age; // The dog's age was deleted, his age was 3
proxyDog.breed = 'Labrador'; // The dog's breed was added, his breed is Labrador his name is Rexy
import { Listeners } from "listen-proxy";

If you find any bugs or errors, please let me know by creating an issue here.

And if you want to contribute, please feel free to do so by opening a PR.


No Bs Ts video

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago