PHP code example of rx / react-promise

1. Go to this page and download the library: Download rx/react-promise library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rx / react-promise example snippets


    
  $observable = \Rx\Observable::of(42);
  $promise = \Rx\React\Promise::fromObservable($observable);
  
  $promise->then(function ($value) {
      echo "Value {$value}\n";
  });
    

    
  $promise = \Rx\React\Promise::resolved(42);
  $observable = \Rx\React\Promise::toObservable($promise);
  
  $observable->subscribe(function ($value) {
      echo "Value {$value}\n";
  });