Skip to content

Commit 6789c89

Browse files
authored
Merge pull request #59 from proposal-signals/this
Pass signal/watcher in via `this`
2 parents 88f3c60 + aa4f10b commit 6789c89

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ namespace Signal {
211211
// A Signal which is a formula based on other Signals
212212
class Computed<T> implements Signal<T> {
213213
// Create a Signal which evaluates to the value returned by the callback.
214-
// Callback is called with this signal as the parameter.
215-
constructor(cb: (s: Computed<T>) => T, options?: SignalOptions<T>);
214+
// Callback is called with this signal as the this value.
215+
constructor(cb: (this: Computed<T>) => T, options?: SignalOptions<T>);
216216
}
217217

218218
namespace subtle {
@@ -239,7 +239,7 @@ namespace Signal {
239239
// When a (recursive) source of Watcher is written to, call this callback,
240240
// if it hasn't already been called since the last `watch` call.
241241
// No signals may be read or written during the notify.
242-
constructor(notify: (w: Watcher) => void);
242+
constructor(notify: (this: Watcher) => void);
243243

244244
// Add these signals to the Watcher's set, and set the watcher to run its
245245
// notify callback next time any signal in the set (or one of its dependencies) changes.
@@ -259,14 +259,14 @@ namespace Signal {
259259

260260
interface SignalOptions<T> {
261261
// Custom comparison function between old and new value. Default: Object.is.
262-
// The signal is passed in as an optionally-used third parameter for context.
263-
equals?: (t: T, t2: T, s: Signal<T>) => boolean;
262+
// The signal is passed in as the this value for context.
263+
equals?: (this: Signal<T>, t: T, t2: T) => boolean;
264264

265265
// Callback called when isWatched becomes true, if it was previously false
266-
[Signal.subtle.watched]?: (s: Signal<T>) => void;
266+
[Signal.subtle.watched]?: (this: Signal<T>) => void;
267267

268268
// Callback called whenever isWatched becomes false, if it was previously true
269-
[Signal.subtle.unwatched]?: (s: Signal<T>) => void;
269+
[Signal.subtle.unwatched]?: (this: Signal<T>) => void;
270270
}
271271
```
272272

0 commit comments

Comments
 (0)