Skip to content

Instantly share code, notes, and snippets.

@Luisgustavom1
Last active November 12, 2022 20:18
Show Gist options
  • Save Luisgustavom1/b89fb4929466d3f195809ed0105011de to your computer and use it in GitHub Desktop.
Save Luisgustavom1/b89fb4929466d3f195809ed0105011de to your computer and use it in GitHub Desktop.
An example of new Proxy use
const user = {
name: 'luis'
}
const messages = {
hello: (userName) => `Ola ${userName}, seja bem vindo ao nosso sistema`,
goodBye: (userName) => `Até mais ${userName}, esperamos que volte sempre aqui`,
}
const messagesHandler = {
get(target, prop, receiver) {
return target[prop](user.name)
},
}
const messagesProxy = new Proxy(messages, messagesHandler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment