1. Go to this page and download the library: Download eserozvataf/scabbia2-events library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Scabbia\Events\Delegate;
$delegate = new Delegate();
// a subscription with priority = 300
$delegate->subscribe(function (...$parameters) {
echo 'first subscriber:';
var_dump($parameters);
}, null, 300);
// a subscription with priority = 1 (will be executed first)
$delegate->subscribe(function (...$parameters) {
echo 'second subscriber, but more important:';
echo count($parameters);
}, null, 1);
$delegate->invoke('a', 'b', 'c');
use Scabbia\Events\Delegate;
$delegate = new Delegate();
$delegate->subscribe(function (...$parameters) {
echo 'first subscriber:';
var_dump($parameters);
// breaks the execution
return false;
});
$delegate->subscribe(function (...$parameters) {
echo 'second subscriber, but not going to be executed:';
echo count($parameters);
});
$delegate->invoke('a', 'b', 'c');
use Scabbia\Events\Events;
$eventsManager = new Events();
$eventsManager->on('click', function (...$parameters) {
echo "clicked on x={$parameters[0]} and y={$parameters[1]}!";
});
$eventsManager->on('double_click', function (...$parameters) {
echo 'double clicked!';
});
$eventsManager->dispatch('click', 5, 10);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.