src/Loader.php
public function set($fx = [], $args = null)
    {
        if (!is_callable($fx)) {
            throw new Exception('Error: Need to pass a callable function to Loader::set()');
        }

        $this->cb->set(function () use ($fx) {
            call_user_func($fx, $this);
            $this->app->terminate($this->renderJSON());
        });

        return $this;
    }
public function set($fx = [], $args = null)
    {
        if (!is_callable($fx)) {
            throw new Exception('Error: Need to pass a callable function to Loader::set()');
        }

        $this->cb->set(function () use ($fx) {
            call_user_func($fx, $this);
            $this->app->terminate($this->renderJSON());
        });

        return $this;
    }
public function set ( $ fx = [ ] , $ args = null ) { if ( ! is_callable ( $ fx ) ) { throw new Exception ( 'Error: Need to pass a callable function to Loader::set()' ) ; } $ this -> cb -> set ( function ( ) use ( $ fx ) { call_user_func ( $ fx , $ this ) ; $ this -> app -> terminate ( $ this -> renderJSON ( ) ) ; } ) ; return $ this ; }
Set callback function for this loader.

The loader view is pass as an argument to the loader callback function.
This allow to easily update the loader view content within the callback.
$l1 = $layout->add('Loader');
$l1->set(function ($loader_view) {
do_long_processing_action();
$loader_view->set('new content');
});

Or
$l1->set([$my_object, 'run_long_process']);

NOTE: default values are like that due ot PHP 7.0 warning:
Declaration of atk4\ui\Loader::set($fx, $args = Array) should be compatible with atk4\ui\View::set($arg1 = Array, $arg2 = NULL)

@param callable $fx
@param array    $args

@throws Exception

@return $this
Set callback function for this loader .