maslosoft / signals
Wireless Cross-Component Communication
Installs: 6 766
Dependents: 9
Suggesters: 1
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 2
Requires
- php: >=7.4
- maslosoft/addendum: ^7@dev
- maslosoft/cli-shared: ^1 | ^2
- maslosoft/embedi: ^2
- psr/log: ^1|^2|^3
- symfony/console: ^5|^6
Requires (Dev)
- codeception/codeception: ^5
- codeception/module-asserts: ^3
- maslosoft/sitcom: ^1 | ^2
- maslosoft/zamm: ^1 | ^2
- roave/security-advisories: dev-latest
- dev-master
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.0.1
- 3.0.0
- 2.0.21
- 2.0.20
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.1.18
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
This package is auto-updated.
Last update: 2024-11-16 10:28:51 UTC
README
Maslosoft Signals
Wireless Cross-Component Communication
Quick Install
composer require maslosoft/signals
Documentation
Connecting components
Various application components must be connected to each other. This should be made in a soft manner, so that when adding or removing component code will not require to change.
Wireless connection
Signals provide somthing like wireless connection between components. On of them emit signal, the other receives it. This can be done other way around. That one application component sends signal, and several components listen to that signal.
Wireless cross-component communication
This component allows for interaction of application components, without prior or explicit assignment.
Setup
Use composer to install
composer require maslosoft/signals:"*"
Or by hard way, download somewhere in your project and ensure autoloading works for Maslosoft\Signals\*
and you include dep too;
Setup signals. After calling init
any further instance will be configured same as below $signal
.
$signal = new Maslosoft\Signals\Signal(); $signal->runtimePath = RUNTIME_PATH; $signal->paths = [ MODELS_PATH ]; $signal->init();
Generate signals definition, only once, hook it to your build script etc.
$signal = new Maslosoft\Signals\Signal(); (new Maslosoft\Signals\Utility($signal))->generate();
Usage
Emiting signal
Define signal:
namespace MyNamespace\Signals; class AccountMenuItems extends AdminMenuItems { public $item = []; }
Define class with slot with @SlotFor
annotation
namespace Maslosoft\Ilmatar\Modules; class MyModule { /** * @SlotFor(MyNamespace\Signals\AccountMenuItems) */ public function reactOnAccountMenu(MyNamespace\Signals\AccountMenuItems $signal) { $signal->item = [ 'url' => '/content/myBlog', 'label' => 'My blog' ]; } }
Emit signal and get results of this call:
$signal = new Maslosoft\Signals\Signal(); $result = $signal->emit(new AdminMenuItems()); echo $result[0]->item[0]['label']; // My blog