77use parallel \Channel ;
88use ReactParallel \Factory ;
99use ReactParallel \ObjectProxy \Generated \ProxyList ;
10- use ReactParallel \ObjectProxy \Message \Call ;
1110use ReactParallel \ObjectProxy \Proxy \CallHandler ;
12- use Rx \Observable ;
1311
1412use function array_key_exists ;
15- use function spl_object_hash ;
1613
1714final class Proxy extends ProxyList
1815{
1916 private const HASNT_PROXYABLE_INTERFACE = false ;
2017
21- private Channel $ output ;
22- private Observable $ outputStream ;
18+ private Factory $ factory ;
2319 private CallHandler $ callHandler ;
2420
2521 public function __construct (Factory $ factory )
2622 {
27- $ this ->output = new Channel (Channel::Infinite);
28- $ this ->outputStream = $ factory ->streams ()->channel ($ this ->output )->share ();
29- $ this ->callHandler = new CallHandler ($ this );
23+ $ this ->factory = $ factory ;
24+ $ this ->callHandler = new CallHandler ($ this );
3025 }
3126
3227 public function has (string $ interface ): bool
@@ -40,14 +35,15 @@ public function create(object $object, string $interface): object
4035 throw NonExistentInterface::create ($ interface );
4136 }
4237
43- $ hash = spl_object_hash ($ object );
44- $ this ->outputStream ->filter (static fn (Call $ call ): bool => $ call ->hash () === $ hash )->subscribe (
38+ $ output = new Channel (Channel::Infinite);
39+
40+ $ this ->factory ->streams ()->channel ($ output )->subscribe (
4541 ($ this ->callHandler )($ object , $ interface )
4642 );
4743
4844 $ class = self ::KNOWN_INTERFACE [$ interface ];
4945
5046 /** @psalm-suppress InvalidStringClass */
51- return new $ class ($ this -> output , $ hash );
47+ return new $ class ($ output );
5248 }
5349}
0 commit comments