PHP Classes

File: test/test_pipeline.php

Recommend this page to a friend!
  Classes of Nikos M.   PHP Publish Subscribe   test/test_pipeline.php   Download  
File: test/test_pipeline.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Publish Subscribe
Register and call handlers of events by name
Author: By
Last change:
Date: 3 years ago
Size: 698 bytes
 

Contents

Class file image Download
<?php

require('../src/php/PublishSubscribe.php');

echo(
'PublishSubscribe.VERSION = ' . PublishSubscribe::VERSION . PHP_EOL);

$pbs = new PublishSubscribe( );
$pbs->on('topic', function($evt){
    echo(
'Sync Handler 1 on topic'.PHP_EOL);
   
$evt->next();
});
$pbs->on('topic', function($evt){
    echo(
'Sync Handler 2 on topic'.PHP_EOL);
   
$evt->next();
});
$pbs->on('topic/subtopic', function($evt){
    echo(
'Sync Handler 1 on topic/subtopic'.PHP_EOL);
   
$evt->next();
});
$pbs->on('topic/subtopic', function($evt){
    echo(
'Sync Handler 2 on topic/subtopic'.PHP_EOL);
   
$evt->next();
});

$pbs->pipeline('topic/subtopic', array(), null, function($evt){
    echo(
'Sync pipeline finished'.PHP_EOL);
});