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