Usage
nebula()->once($unique_id, $callback, ...$args)
Parameters
$unique_id
(Required) (String) A unique string
Default: None
$callback
(Required) (Function) The function to trigger one time only
Default: None
...$args
(Optional) (Variadic) The parameters for the function
Default: None
Parameter Notes
Important! The order of the parameters for this PHP function is different than the order of parameters for the JavaScript once() function!
Examples
Do something only once
$this->once('this is an example', function(){
echo 'This will output only once!';
});
Do something once and pass variables into the once function
$this->once('this is an example', function($foo, $bar){
echo 'This will output only once: ' . $foo . ' and ' . $bar;
}, $foo, $bar); //Pass as many parameters as you'd like
Source File
Located in /libs/Utilities/Utilities.php on line 42.
No Hooks
This function does not have any filters or actions available. Request one? public function once($unique_id, $callback, ...$args){
static $called = array();
if ( !isset($called[$unique_id]) ){
$called[$unique_id] = true;
$callback(...$args);
}
}
Override
This function can not be short-circuited with an override filter. Request one?