Skip to content

Commit

Permalink
Merge pull request #234 from prophile/no-state-on-state
Browse files Browse the repository at this point in the history
Make clear that `Signal.State` has no state machine
  • Loading branch information
NullVoxPopuli authored Aug 6, 2024
2 parents 3490f52 + aa654ab commit acd4093
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,14 +462,13 @@ Signal algorithms need to reference certain global state. This state is global f
- `unwatched`: The callback to be called when the signal is no longer observed by an effect
- `sinks`: Set of watched signals which depend on this one
#### Constructor: `Signal(initialValue, options)`
#### Constructor: `Signal.State(initialValue, options)`
1. Set this Signal's `value` to `initialValue`.
1. Set this Signal's `equals` to options?.equals
1. Set this Signal's `watched` to options?.[Signal.subtle.watched]
1. Set this Signal's `unwatched` to options?.[Signal.subtle.unwatched]
1. Set this Signal's `sinks` to the empty set
1. Set `state` to `~clean~`.
#### Method: `Signal.State.prototype.get()`
Expand Down Expand Up @@ -552,7 +551,7 @@ With [AsyncContext](https://github.com/tc39/proposal-async-context), the callbac
1. If `computing` is not `null`, add this Signal to `computing`'s `sources` set.
1. NOTE: We do not add `computing` to this Signal's `sinks` set until/unless it becomes watched by a Watcher.
1. If this Signal's state is `~dirty~` or `~checked~`: Repeat the following steps until this Signal is `~clean~`:
1. Recurse up via `sources` to find the deepest, left-most (i.e. earliest observed) recursive source which is marked `~dirty~` (cutting off search when hitting a `~clean~` Signal, and including this Signal as the last thing to search).
1. Recurse up via `sources` to find the deepest, left-most (i.e. earliest observed) recursive source which is a Computed Signal marked `~dirty~` (cutting off search when hitting a `~clean~` Computed Signal, and including this Computed Signal as the last thing to search).
1. Perform the "recalculate dirty computed Signal" algorithm on that Signal.
1. At this point, this Signal's state will be `~clean~`, and no recursive sources will be `~dirty~` or `~checked~`. Return the Signal's `value`. If the value is an exception, rethrow that exception.
Expand Down Expand Up @@ -627,7 +626,7 @@ With [AsyncContext](https://github.com/tc39/proposal-async-context), the callbac
#### Method: `Signal.subtle.Watcher.prototype.getPending()`
1. Return an Array containing the subset of `signals` which are in the state `dirty` or `pending`.
1. Return an Array containing the subset of `signals` which are Computed Signals in the states `~dirty~` or `~pending~`.
### Method: `Signal.subtle.untrack(cb)`
Expand Down

0 comments on commit acd4093

Please sign in to comment.