| Recommend this page to a friend! | 
|  Download | 
| Info | Documentation |  Files |  Install with Composer |  Download | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not yet rated by the users | Total: 62 | All time:  10,469 This week: 660  | ||||
| Version | License | PHP version | Categories | |||
| preact 1.0.1 | The PHP License | 5 | PHP 5, Validation, Language | 
| Description | Author | |||||||||||||||||||||||
| This package can be used for asking confirmation before actions they are executed. Innovation Award | 
 | |||||||||||||||||||||||
Performs action before-hand, confirms action execution.<br/> This program uses ReactPHP Promise for its promise implementation.
composer require ahmard/preact
An event system for simple event-driven programming.
use Preact\Event;
$event = new Event();
$event->on('user.created', function ($user){
    echo "User created: {$user['name']}";
});
$user = [
    'id' => 1,
    'name' => 'Admin'
];
$event->emit('user.created', [$user]);
You can use Preact\EventTrait trait directly in your class and have the functionality embedded in your code.
namespace App\User;
use Preact\EventTrait;
class User
{
    use EventTrait;
    
    public function create(array $userInfo)
    {
        //Save in DB
        $this->emit('created', [$userInfo]);
    }
}
$user = new User;
$user->on('created', function ($user){
    echo "User created: {$user['username']}\n";
});
$user->create([
    'username' => 'Admin',
    'email' => '[email protected]'
]);
Have confirmation before execution.
use React\Promise\PromisorInterface;
use Preact\PreactTrait;
class Animal
{
    use PreactTrait;
}
$animal = new Animal();
$animal->onPreact('can.create', function (PromisorInterface $promisor, $animalInfo){
    if($animalInfo['name'] == 'lion'){
        $promisor->resolve(true);
    }else{
        $promisor->reject(false);
    }
});
$animal->preact('can.create', ['lion'])
    ->then(function (){
        echo 'Animal creation allowed: lion';
    })
    ->otherwise(function (){
        echo 'Animal creation rejected: lion.\n';
    });
To see more use cases view examples.
Preact is MIT licenced.
|  Files (15) | 
| File | Role | Description | ||
|---|---|---|---|---|
|  examples (3 files) | ||||
|  src (6 files) | ||||
|  tests (2 files) | ||||
|    composer.json | Data | Auxiliary data | ||
|    composer.lock | Data | Auxiliary data | ||
|    phpunit.xml | Data | Auxiliary data | ||
|    README.md | Doc. | Documentation | ||
|  Files (15) | / | examples | 
| File | Role | Description | 
|---|---|---|
|  advance-preact.php | Class | Class source | 
|  simple-event.php | Class | Class source | 
|  simple-preact.php | Class | Class source | 
|  Files (15) | / | src | 
| File | Role | Description | 
|---|---|---|
|  Event.php | Class | Class source | 
|  EventInterface.php | Class | Class source | 
|  EventTrait.php | Class | Class source | 
|  Preact.php | Class | Class source | 
|  PreactInterface.php | Class | Class source | 
|  PreactTrait.php | Class | Class source | 
|  Files (15) | / | tests | 
| File | Role | Description | 
|---|---|---|
|  EventTest.php | Class | Class source | 
|  PreactTest.php | Class | Class source | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
|  Install with Composer | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
 | 
 | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.
 If you know an application of this package, send a message to the author to add a link here.