PHP Classes

File: test/test_filter.js

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

Contents

Class file image Download
"use strict"; var PublishSubscribe = require('../src/js/PublishSubscribe.js'), echo = console.log; echo('PublishSubscribe.VERSION = ' + PublishSubscribe.VERSION); function filter(pb, hook, value, args) { var data = {}; if ( args ) { for(var k in args) data[k] = args[k]; } data.value = value; return new Promise(function(resolve,reject){ pb.pipeline(hook, data, null, function(evt){ echo('FINISH'); resolve(evt.data.value); }); }); } var pb = new PublishSubscribe( ); pb.on('filter_value', function(evt){ echo(evt.data); evt.data.value++; setTimeout(function(){evt.next();}, 100); }); pb.on('filter_value', function(evt){ echo(evt.data); evt.data.value++; evt.next(); }); pb.on('filter_value', function(evt){ echo(evt.data); evt.data.value++; evt.next(); }); filter(pb, 'filter_value', 2).then(function(value){echo(value);});