forked from BaylorRae/PubSub-PHP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
34 lines (26 loc) · 792 Bytes
/
index.php
File metadata and controls
34 lines (26 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require 'PubSub.php';
// This is the original subscription
// All others should eventually need to call this one, but it's not necessary
// because it's __extendable__
PubSub::subscribe('sayHello', function($name) {
echo "<p>Hello $name</p>";
}, 'extendable');
PubSub::subscribe('sayHello', function($name) {
$name = strtolower(str_replace(' ', '-', $name));
PubSub::super($name);
});
PubSub::subscribe('lol', function() {
echo 'lol';
}, 'extendable'); // try changing "extendable" to 'standard' or 'locked'
PubSub::subscribe('lol', function() {
echo 'I said ';
PubSub::super();
});
PubSub::subscribe('lol', function() {
echo 'Dad and ';
PubSub::super();
});
// PubSub::unsubscribe('sayHello');
PubSub::publish('sayHello', "Baylor Rae'");
PubSub::publish('lol');