hhpack / publisher
Simple implementation of Pub/Sub for Hack
Installs: 487
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Language:Shell
Requires
- hhvm: >=3.21.0
- hhvm/hhvm-autoload: ^2.0
Requires (Dev)
- facebook/fbexpect: ^2.5
- hhvm/hacktest: ^1.5
README
Simple implementation of Pub/Sub for Hack.
Basic usage
Usage is very simple, You just implement Message the Subscriber.
The following are register to MessagePublisher and just publish a message.
namespace domain; use HHPack\Publisher\Message; use HHPack\Publisher\Subscribable; use HHPack\Publisher\MessagePublisher; final class DomainMessage implements Message { } final class DomainMessageSubscriber implements Subscribable<Message> { public async function onDomainMessage(DomainMessage $message) : Awaitable<void> { await async_task1(); await async_task2(); } } $publisher = new MessagePublisher(); $publisher->registerSubscriber(new DomainMessageSubscriber()); await $publisher->publish(new DomainMessage());
Run the test
You can run the test with the following command.
composer install
composer test