PHP code example of xtompie / rensen

1. Go to this page and download the library: Download xtompie/rensen 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/ */

    

xtompie / rensen example snippets


use Xtompie\Rensen\R;

// Define reactive values
$a = new R(fn() => 1);
$b = new R(fn() => 2);

// Create a dependent reactive value
$c = new R(fn() => $a() + $b());

// React to changes in $c
new R(fn() => print("c: {$c()}\n"));

// Initial output:
// c: 3

// Change $a
$a(fn() => 10);

// Outputs:
// c: 12