🗼 Let Promise Function Executed Only Once.
The
Promisewill be executed when the attribute target is called for the first time, and thePromiseexecuted will not be executed again when called repeatedly.
The same
Promisewill not be executed twice at the same time. Only the first one will be executed, while the rest can still get the result of thepromiseafter executed.
If you are looking for the pure version of once-init(without ref), click me 国内镜像
- The
Promise Functionpackaged byRefOnceInitwill never be executed twice at the same time - If A
Promise Functionis called before previousPromise Functionresolved, It will share the response of the previous one. - Example Site
Install by package management tools, pnpm is recommended;
npm install ref-once-initOR
yarn add ref-once-initOR
pnpm add ref-once-initFor example, use ref-once-init with axios;