File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,6 @@ public function __construct(PromiseInterface $promise)
28
28
{
29
29
$ out = $ this ;
30
30
31
- // TODO: support backpressure
32
-
33
31
$ this ->promise = $ promise ->then (
34
32
function ($ stream ) {
35
33
if (!($ stream instanceof ReadableStreamInterface)) {
@@ -78,10 +76,16 @@ public function isReadable()
78
76
79
77
public function pause ()
80
78
{
79
+ $ this ->promise ->then (function (ReadableStreamInterface $ stream ) {
80
+ $ stream ->pause ();
81
+ });
81
82
}
82
83
83
84
public function resume ()
84
85
{
86
+ $ this ->promise ->then (function (ReadableStreamInterface $ stream ) {
87
+ $ stream ->resume ();
88
+ });
85
89
}
86
90
87
91
public function pipe (WritableStreamInterface $ dest , array $ options = array ())
Original file line number Diff line number Diff line change @@ -164,4 +164,26 @@ public function testEmitsCloseOnlyOnceWhenClosingStreamMultipleTimes()
164
164
$ stream ->close ();
165
165
$ stream ->close ();
166
166
}
167
+
168
+ public function testForwardsPauseToInputStream ()
169
+ {
170
+ $ input = $ this ->getMock ('React\Stream\ReadableStreamInterface ' );
171
+ $ input ->expects ($ this ->once ())->method ('pause ' );
172
+
173
+ $ promise = Promise \resolve ($ input );
174
+ $ stream = Stream \unwrapReadable ($ promise );
175
+
176
+ $ stream ->pause ();
177
+ }
178
+
179
+ public function testForwardsResumeToInputStream ()
180
+ {
181
+ $ input = $ this ->getMock ('React\Stream\ReadableStreamInterface ' );
182
+ $ input ->expects ($ this ->once ())->method ('resume ' );
183
+
184
+ $ promise = Promise \resolve ($ input );
185
+ $ stream = Stream \unwrapReadable ($ promise );
186
+
187
+ $ stream ->resume ();
188
+ }
167
189
}
You can’t perform that action at this time.
0 commit comments