WA-230 moving ensureOnce util function to singleton.js
This commit is contained in:
parent
0094abd4ac
commit
e33077b752
|
@ -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…
Reference in New Issue