You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adev/src/content/guide/signals/overview.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -195,6 +195,29 @@ Equality functions can be provided to both writable and computed signals.
195
195
196
196
HELPFUL: By default, signals use referential equality ([`Object.is()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/is) comparison).
197
197
198
+
### Type checking signals
199
+
200
+
You can use `isSignal` to check if a value is a `Signal`:
201
+
202
+
```ts
203
+
const count =signal(0);
204
+
const doubled =computed(() =>count() *2);
205
+
206
+
isSignal(count); // true
207
+
isSignal(doubled); // true
208
+
isSignal(42); // false
209
+
```
210
+
211
+
To specifically check if a signal is writable, use `isWritableSignal`:
212
+
213
+
```ts
214
+
const count =signal(0);
215
+
const doubled =computed(() =>count() *2);
216
+
217
+
isWritableSignal(count); // true
218
+
isWritableSignal(doubled); // false
219
+
```
220
+
198
221
### Reading without tracking dependencies
199
222
200
223
Rarely, you may want to execute code which may read signals within a reactive function such as `computed` or `effect`_without_ creating a dependency.
0 commit comments