Reactivity with Signals Learn how Semantic UI uses signals to produce reactivity cpu Guide

Reactivity with Signals

Reactivity provides primitives for a signals-based reactivity system. It is used internally to power templating and rendering components, but can also be used as reactivity primitives for any custom project.

Installation

Reactivity can be used as a standalone package or alongside Semantic UI components.

Terminal window
npm install @semantic-ui/reactivity

Basic Usage

import { ReactiveVar, Reaction } from '@semantic-ui/reactivity';
const counter = new ReactiveVar(0);
Reaction.create(() => {
console.log('Counter value:', counter.get());
});
counter.set(1); // Console: "Counter value: 1"

API Sections

  • ReactiveVar - Core class for creating reactive variables
  • Reaction - Managing reactive computations
  • Dependency - Low-level dependency tracking
  • Flushing - Controlling the execution of reactions

Data Type Helpers

Semantic UI includes various helpers to make it easy to manipulate data like arrays, records (arrays of objects), counters, toggles, and streamline data manipulation.

These helpers provide convenient ways to manipulate reactive data structures and streamline common operations in your reactive computations.