Skip to content

Instantly share code, notes, and snippets.

@theKashey
Created October 19, 2018 00:42
Show Gist options
  • Select an option

  • Save theKashey/500eea7250d073b0eafffa5bdf39e079 to your computer and use it in GitHub Desktop.

Select an option

Save theKashey/500eea7250d073b0eafffa5bdf39e079 to your computer and use it in GitHub Desktop.
// we will "cache" hello using the current language
// of course it will never change :P
let helloMessage = '';
export const sayHello = (inLng) => {
if (!helloMessage) {
helloMessage = require('hello-message-generator')(inLng);
}
return helloMessage
}
// ok, lets delete ourself from a cache, so a new customer will get this file
// WITHOUT cached `helloMessage`
// you know - only one of those commands works in a single point of time and space
delete require.cache[require.resolve(__filename)]; // wipe yourself from a nodejs cache
delete __webpack_require__.c[module.id]; // wipe yourself from a webpack cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment