---
title: "Reactivity - s&box library"
description: "A reactive property system for components"
canonical: "https://sbox.watch/ru/libraries/igor/reactivity/"
generated_at: "2026-10-09T10:45:14.988Z"
---

# Reactivity

A reactive property system for components

- Тип: библиотека
- Идентификатор: igor.reactivity
- Автор: igor
- Канонический URL: https://sbox.watch/ru/libraries/igor/reactivity/
- Markdown: https://sbox.watch/ru/libraries/igor/reactivity/index.md
- sbox.game: https://sbox.game/igor/reactivity/
- Создано: 2026-10-09T10:45:14.988Z

## Статистика

- динамика за 24 ч: +0
- Terry Score: 27%
- Избранное: 0
- Положительные оценки: 1
- Отрицательные оценки: 0
- Обновлено: 27 июн. 2026 г.
- Создано: 7 февр. 2026 г.
- Размер: 189.5 KB
- Файлы: 47
- Теги: effects, events, framework, reactive

## Описание

sbox-reactivity
A reactivity system for s&box. It makes writing code that runs in response to state changes easy. Check out https://github.com/impulsh/sbox-reactivity for documentation.

public class MyComponent : ReactiveComponent
{
 \[Property, Reactive\]
 public float Speed { get; set; } = 50f;

 \[Reactive, Derived(nameof(\_tintColor))\]
 public Color TintColor { get; } = Color.Blue;

 private Color \_tintColor()
 {
 // Calculate the tint color only when the speed changes
 return Math.Abs(Speed) <= 100f ? Color.Blue : Color.Red;
 }

 protected override void OnActivate()
 {
 Effect(() =>
 {
 // Create a game object when this component is enabled
 var go = new GameObject();
 var model = go.AddComponent<ModelRenderer>();
 model.Model = Model.Cube;

 // Tint the model whenever it changes
 Effect(() => model.Tint = TintColor);

 // Spin the object every frame while the component is enabled
 Frame(() =>
 {
 var angles = go.LocalRotation.Angles();
 angles.yaw += Speed \* Time.Delta;

 go.LocalRotation = angles;
 });

 // Destroy the object when the component is disabled
 return () => go.Destroy();
 });
 }
}



