Created
October 19, 2018 00:42
-
-
Save theKashey/500eea7250d073b0eafffa5bdf39e079 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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