mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-27 01:50:44 +00:00
WA-230 moving ensureOnce util function to singleton.js
This commit is contained in:
parent
0094abd4ac
commit
e33077b752
14
src/utils/singleton.js
Normal file
14
src/utils/singleton.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// @flow
|
||||||
|
export const ensureOnce = (fn: Function): Function => {
|
||||||
|
let executed = false
|
||||||
|
let response
|
||||||
|
|
||||||
|
return (...args) => {
|
||||||
|
if (executed) { return response }
|
||||||
|
|
||||||
|
executed = true
|
||||||
|
response = fn(args)
|
||||||
|
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user