xtompie/rensen
最新稳定版本:1.0.1
Composer 安装命令:
composer require xtompie/rensen
包简介
README 文档
README
The Rensen library provides a lightweight reactive system for PHP. It allows you to create reactive values that automatically update when dependencies change.
Features
- Define reactive values (
R) that automatically recompute when their dependencies change. - Efficient dependency tracking with minimal state.
Requirements
- PHP >= 8.0
Installation
Using Composer:
composer require xtompie/rensen
Usage
The following example demonstrates how to define reactive values and react to their changes:
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
Explanation
- Reactive values (
R) are created using a callable. - Dependencies are automatically tracked. For example,
$cdepends on$aand$b. - When a dependency changes, all dependent values and reactions are updated.
Why Rensen?
Rensen brings a reactive programming model to PHP. Inspired by modern frontend frameworks, it enables automatic propagation of changes in a simple and efficient way.
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-02