Skip to content

Commit

Permalink
add callback error unrolling test
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 27, 2021
1 parent 848772c commit e8030a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions demos/_unit-test/callback-nested.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,33 @@
$loader = Loader::addTo($app);
$loader->loadEvent = false;

$loader->set(function ($p) use ($m) {
$loader_1 = Loader::addTo($p);
$loader_1->loadEvent = false;
$loader->set(function (Loader $p) use ($m) {
if (!empty($_GET['err_main_loader'])) {
throw new Exception('Exception from Main Loader');
}

$loaderSub = Loader::addTo($p);
$loaderSub->loadEvent = false;

Header::addTo($p, ['Loader-1', 'size' => 4]);

$loader_1->set(function ($p) use ($m) {
$loaderSub->set(function (Loader $p) use ($m) {
if (!empty($_GET['err_sub_loader'])) {
throw new Exception('Exception from Sub Loader');
}

Header::addTo($p, ['Loader-2', 'size' => 4]);
$loader_3 = Loader::addTo($p);

$loader_3->set(function ($p) use ($m) {
$loaderSubSub = Loader::addTo($p);

$loaderSubSub->set(function (Loader $p) use ($m) {
Header::addTo($p, ['Loader-3', 'size' => 4]);

$c = Crud::addTo($p, ['ipp' => 4]);
$c->setModel($m, [$m->fieldName()->name]);
});
});
\Atk4\Ui\Button::addTo($p, ['Load2'])->js('click', $loader_1->jsLoad());
\Atk4\Ui\Button::addTo($p, ['Load2'])->js('click', $loaderSub->jsLoad());
});

\Atk4\Ui\Button::addTo($app, ['Load1'])->js('click', $loader->jsLoad());
2 changes: 1 addition & 1 deletion src/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Loader extends View
public $shim;

/**
* Specify which event will cause Loader to begen fetching it's actual data. In some cases
* Specify which event will cause Loader to begin fetching it's actual data. In some cases
* you would want to wait. You can set a custom JavaScript event name then trigger() it.
*
* Default value is `true` which means loading will take place as soon as possible. Setting this
Expand Down

0 comments on commit e8030a8

Please sign in to comment.