once

function once(func: Function): () => any

Ensures a function is only executed once.

const initialize = Utils.once(() => console.log('Initialized!'));
initialize(); // 'Initialized!'
initialize(); // (No output)
Parameter
Type
Optional
Description

func

Function

The function to only execute once

Last updated