Skip to content

Commit d982740

Browse files
authored
Merge pull request #20 from clue-labs/examples
Update example to use new Stream v0.6 API
2 parents c44c94c + e0be8e3 commit d982740

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ It wraps a given `ReadableStreamInterface` and exposes its plain data through
2424
the same interface.
2525

2626
```php
27-
$stdin = new Stream(STDIN, $loop);
27+
$stdin = new ReadableResourceStream(STDIN, $loop);
2828

2929
$stream = new ControlCodeParser($stdin);
3030

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"require-dev": {
2121
"phpunit/phpunit": "^5.0 || ^4.8",
22-
"react/event-loop": "^0.4 || ^0.3"
22+
"react/event-loop": "^0.4 || ^0.3",
23+
"react/stream": "^0.6"
2324
}
2425
}

examples/random-colors.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
// with random colors:
1212
// $ phpunit --color=always | php random-colors.php
1313

14-
use React\Stream\Stream;
1514
use React\EventLoop\Factory;
1615
use Clue\React\Term\ControlCodeParser;
16+
use React\Stream\ReadableResourceStream;
17+
use React\Stream\WritableResourceStream;
1718

1819
require __DIR__ . '/../vendor/autoload.php';
1920

@@ -25,11 +26,10 @@
2526
}
2627

2728
// process control codes from STDIN
28-
$stdin = new Stream(STDIN, $loop);
29+
$stdin = new ReadableResourceStream(STDIN, $loop);
2930
$parser = new ControlCodeParser($stdin);
3031

31-
$stdout = new Stream(STDOUT, $loop);
32-
$stdout->pause();
32+
$stdout = new WritableResourceStream(STDOUT, $loop);
3333

3434
// pass all c0 codes through to output
3535
$parser->on('c0', array($stdout, 'write'));

examples/remove-codes.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
// codes like this:
99
// $ phpunit --color=always | php remove-codes.php
1010

11-
use React\Stream\Stream;
1211
use React\EventLoop\Factory;
1312
use Clue\React\Term\ControlCodeParser;
13+
use React\Stream\ReadableResourceStream;
14+
use React\Stream\WritableResourceStream;
1415

1516
require __DIR__ . '/../vendor/autoload.php';
1617

@@ -22,13 +23,11 @@
2223
}
2324

2425
// process control codes from STDIN
25-
$stdin = new Stream(STDIN, $loop);
26+
$stdin = new ReadableResourceStream(STDIN, $loop);
2627
$parser = new ControlCodeParser($stdin);
2728

28-
$stdout = new Stream(STDOUT, $loop);
29-
$stdout->pause();
30-
3129
// pipe data from STDIN to STDOUT without any codes
30+
$stdout = new WritableResourceStream(STDOUT, $loop);
3231
$parser->pipe($stdout);
3332

3433
// only forward \r, \n and \t

examples/stdin-codes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
// codes like this:
1010
// $ phpunit --color=always | php stdin-codes.php
1111

12-
use React\Stream\Stream;
1312
use React\EventLoop\Factory;
1413
use Clue\React\Term\ControlCodeParser;
14+
use React\Stream\ReadableResourceStream;
1515

1616
require __DIR__ . '/../vendor/autoload.php';
1717

@@ -23,7 +23,7 @@
2323
}
2424

2525
// process control codes from STDIN
26-
$stdin = new Stream(STDIN, $loop);
26+
$stdin = new ReadableResourceStream(STDIN, $loop);
2727
$parser = new ControlCodeParser($stdin);
2828

2929
$decoder = function ($code) {

0 commit comments

Comments
 (0)