xtompie/rensen 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Reactive values (R) are created using a callable.
  2. Dependencies are automatically tracked. For example, $c depends on $a and $b.
  3. 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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-02