Reactivity

Library

A reactive property system for components

igor updated 3mo ago 0 MB engine 26
thumb_up 1 open_in_new View on sbox.game
Reactivity

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();
		});
	}
}
1
Total Users
3
Total Sessions
6 min
Total Playtime
0 recorded entries
Rank Player Score Recorded
refresh
Discovering package leaderboards...
Package ID: igor.reactivity
Created: 2026-02-07 05:34 UTC
Updated: 2026-06-27 21:09 UTC
Type: library
Public: Yes
Version: 302096
files: 47
Size: 0.2 MB
Engine Version: 26
Asset Version ID: 302096
Version Created: 2026-06-27 21:09 UTC
Hash: 1782594598
Manifest: Open manifest

more_horiz Additional Properties

Compiler: {"RootNamespace":"Sandbox.Reactivity","DefineConstants":"SANDBOX","NoWarn":"1701;1702;1591;","WarningsAsErrors":"","TreatWarningsAsErrors":false,"Nullables":true,"ReleaseMode":"Debug","AssemblyReferences":[],"ReplacementDirectives":{".Server.cs":"SERVER"},"IgnoreFolders":[],"DistinctAssemblyReferences":[]}
new_releases Latest Update Jun 27, 2026
Fix debug info exception outside of game project
302096 Jun 27, 2026
Fix debug info exception outside of game project
167723 Mar 29, 2026
Fix editor content
167719 Mar 29, 2026
Add infinite loop inspector
166668 Mar 27, 2026
Add reactivity debugger
160359 Mar 8, 2026
Allow ReactiveComponent activation during OnStart
156563 Feb 27, 2026
Fix state mutation in effect not causing re-run
156144 Feb 25, 2026
Support reactivity attributes on static properties
155734 Feb 24, 2026
Add GetEffectCancelToken
154843 Feb 21, 2026
Add Each method
154475 Feb 19, 2026
Add tick/frame methods
info Live API Passthrough & Removal Notice

This file manifest and asset metadata are retrieved live directly from the official Facepunch s&box public API. s&box Explorer does not host, store, or redistribute any package files. All download links route directly to Facepunch CDN servers.