Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (15) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2020-10-19 (19 hours ago) | Not yet rated by the users | Total: Not yet counted | Not yet ranked |
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. |
|
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' => 'admin@test.local'
]);
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 |
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 | / | examples |
File | Role | Description |
---|---|---|
advance-preact.php | Class | Class source |
simple-event.php | Class | Class source |
simple-preact.php | Class | Class source |
Files | / | 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 | / | tests |
File | Role | Description |
---|---|---|
EventTest.php | Class | Class source |
PreactTest.php | Class | Class source |
Version Control | Unique User Downloads | |||||||
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.