Skip to content

sciflydev/StateSignals.jl

Repository files navigation

StateSignals

Test workflow status BestieTemplate

This package implements a reactive graph-based state management system where values automatically update based on their dependencies. It is inspired by the Angular JS framework and built around three core concepts:

  • Signal: wraps a value and notifies dependents when it changes.
  • Computed signal: automatically derived values that update when their dependencies change.
  • Effect: callback that run when its dependent signals change.

Simple example:

using StateSignals
x = Signal(1)
y = Signal(2)
z = computed(() -> x() + y())  # z is 3
effect(() -> println("Sum changed to: ", z()))

x(5) # Prints "Sum changed to: 7"

Using resources for long computations:

using StateSignals

s = Signal(0)
r = Resource([s]) do
    sleep(3)
    println("Resource acquired")
    s()*3
end
s(3)

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages