PHP code example of ltsc / simple-event

1. Go to this page and download the library: Download ltsc/simple-event 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/ */

    

ltsc / simple-event example snippets


$event = LTSC\Event\Event::getInstance();
$event->on('click', function($msg) {
    echo $msg;
});
$event->trigger('click', 'Hello');

$events = LTSC\Event\Events::getInstance();
$events->add('click', 99, function($msg) {
    echo "My order is 99, argument is $msg";
});
$event->emit('click', 'Hello');


$events = LTSC\Event\CustomEvents::getInstance(
    new \LTSC\Event\Helper\CEConfigure(
        Parent_Class::class,
        'call_method',
        ['arguments_for_construct']
    )
);
$list = $events->getEventList(); //all event names which allowed is add here
$list->add('click', 0); //max events for click, 0 is no limit
$events->addEvents('click', MyEvents::class);
$events->call('click', 'Hello');