static class · System.Reactive
Reactive
public static class Reactive
- Tipo
- static class
- Espacio de nombres
- System.Reactive
- Ensamblado
- System.Core
- Acceso
- public, static, abstract
- Archivo fuente
Reactive.ant
Herencia
- Clases base
-
AnyReactive
Métodos
Runs body now, and again whenever a reactive value it read changes.
Batch(func body)
#
Runs body; the effects its changes trigger run once each when it is done.
Runs an effect now, or once at the end of the batch in progress.
Flush()
#
Campos
Miembros privados e internos (3)
Computes a lazy effect now, also inside a batch: a read of a computed sees the current values, not what it kept before the batch changed something it depends on. One scheduled in the batch is done with (it does not go stale again when the batch ends).
Miembros heredados (5)
GetTypemétodo de AnyUndescribedmétodo de AnyToStringmétodo de AnyHashmétodo de Anydestroymétodo de Any
Código fuente
Reactive en Antril, descompilado a partir de su Larva HIR.
// System.Reactive.Reactive — System.Core (decompiled from Larva HIR)
import System;
into namespace System.Reactive
{
public static class Reactive
{
i32 depth;
List<Effect?> pending;
internal:
/// Computes a lazy effect now, also inside a batch: a read of a computed sees the current values, not what it
/// kept before the batch changed something it depends on. One scheduled in the batch is done with (it does
/// not go stale again when the batch ends).
Refresh(Effect tracker)
{
if (tracker.Pending)
{
tracker.Pending = false;
i32 at = tracker.PendingAt;
if (at < pending.Count && pending[at] == tracker)
pending[at] = null;
tracker.Trigger();
}
if (tracker.Stale)
tracker.Run();
}
public:
/// The effect running now (what a Source being read should track), or null.
Effect? Current;
/// Runs `body` now, and again whenever a reactive value it read changes.
Watch(func body) : Effect
{
Effect effect = new Effect(body);
effect.Run();
return effect;
}
/// Runs `body`; the effects its changes trigger run once each when it is done.
Batch(func body)
{
depth++;
try
{
body();
}
finally
{
depth--;
if (depth == 0)
Flush();
}
}
/// Runs an effect now, or once at the end of the batch in progress.
Schedule(Effect effect)
{
if (depth == 0)
{
effect.Trigger();
return;
}
if (!effect.Pending)
{
effect.Pending = true;
effect.PendingAt = pending.Count;
pending.Add(effect);
}
}
Flush()
{
List<Effect?> due = pending;
pending = new List<Effect?>();
loop (i32 i = 0..due.Count)
{
if (due[i] is Effect effect)
{
effect.Pending = false;
effect.Trigger();
}
}
}
}
}