Skip to content

Commit c3114f0

Browse files
committed
Fix Mark and Level documentation in IAdaptiveObject
Corrected two misunderstandings in the core adaptive object interface: Mark() method: - OLD (incorrect): "Returns true if newly marked, false if already marked" - NEW (correct): Return value controls change propagation - Return TRUE to continue propagating to outputs (normal) - Return FALSE to stop propagation (no outputs marked) - Documented that Mark() is where callbacks are executed - Explained common use cases: - Constants return false (stop propagation) - Callbacks execute here before returning true - Custom logic can conditionally stop propagation - Added note about execution context (locked, after AllInputsProcessed) Level property: - OLD (incorrect): "Used during evaluation to ensure topological order" - NEW (correct): Determines ORDER of marking during change propagation - Objects marked in increasing level order (0, 1, 2, ...) - Ensures outputs marked after inputs (topological order) - Does NOT influence evaluation order - only marking order - Level 0 = input cells (cval, clist, cset, cmap) - Higher levels = derived values/collections Key insight: Level affects WHEN objects are marked in transactions, not when they are evaluated. Evaluation is pull-based and lazy. Thanks to user feedback for catching these misunderstandings! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8f3725b commit c3114f0

File tree

1 file changed

+17
-6
lines changed
  • src/FSharp.Data.Adaptive/Core

1 file changed

+17
-6
lines changed

src/FSharp.Data.Adaptive/Core/Core.fs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,30 @@ type IAdaptiveObject =
3333
abstract member Weak: WeakReference<IAdaptiveObject>
3434

3535
/// The maximal distance from an input cell in the dependency graph.
36-
/// Used during transaction-based evaluation to ensure topological order.
37-
/// Higher levels are evaluated after lower levels to maintain consistency.
36+
/// Used to determine the ORDER in which objects are marked during change propagation.
37+
/// Objects are marked in order of increasing level (level 0 first, then 1, then 2, etc.).
38+
/// This ensures outputs are marked after their inputs, maintaining topological order.
3839
/// Input cells (cval, clist, etc.) have level 0.
40+
/// The level does NOT influence evaluation order - only marking order during transactions.
3941
abstract member Level: int with get, set
4042

4143
///// Used internally to ensure that AdaptiveObjects are not marked while their value
4244
///// is still needed by an evaluation.
4345
//abstract member ReaderCount: int with get, set
4446

45-
/// Marks this object as out-of-date during change propagation.
46-
/// Returns true if the object was previously up-to-date and is now marked.
47-
/// Returns false if the object was already marked or is constant.
48-
/// This method is called during transaction processing when inputs change.
47+
/// Called during change propagation to mark this object as out-of-date.
48+
/// This is where you can realize callbacks when the object becomes dirty.
49+
///
50+
/// Return value controls propagation:
51+
/// - Return TRUE to continue propagating changes to outputs (normal behavior)
52+
/// - Return FALSE to stop propagation (prevents outputs from being marked)
53+
///
54+
/// Common uses:
55+
/// - Constant objects return false (no outputs should be marked)
56+
/// - Objects with callbacks execute them here before returning true
57+
/// - Custom objects can conditionally stop propagation based on logic
58+
///
59+
/// Called with the object locked, after AllInputsProcessed, before outputs are consumed.
4960
abstract member Mark: unit -> bool
5061

5162
/// Indicates whether the object's cached value is out-of-date.

0 commit comments

Comments
 (0)