Skip to content

Commit ae430bb

Browse files
authored
deprecate watch and derive (#1190)
1 parent 9ad5228 commit ae430bb

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

docs/api/utils/derive.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ description: 'create a new proxy derived from others'
77

88
## `derive`
99

10+
> **⚠️ Deprecated**
11+
>
12+
> This package is no longer maintained. Please migrate to
13+
> [valtio-reactive](https://github.com/valtiojs/valtio-reactive).
14+
1015
## Installation
1116

1217
```bash

docs/api/utils/watch.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ description: 'watch for changes.'
77

88
# `watch`
99

10+
> **⚠️ Deprecated**
11+
>
12+
> This util is no longer maintained. Please migrate to
13+
> [valtio-reactive](https://github.com/valtiojs/valtio-reactive).
14+
1015
## Subscription via a getter
1116

1217
This utility supports subscribing to multiple proxy objects (unlike `subscribe` which listens to only a single proxy). Proxy objects are subscribed with a `get` function passed to the callback.

src/vanilla/utils/watch.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ type WatchOptions = {
1111

1212
let currentCleanups: Set<Cleanup> | undefined
1313

14+
let didWarnDeprecation = false
15+
1416
/**
1517
* watch
1618
*
19+
* @deprecated This util is no longer maintained. Please migrate to [valtio-reactive](https://github.com/valtiojs/valtio-reactive).
20+
*
1721
* Creates a reactive effect that automatically tracks proxy objects and
1822
* reevaluates everytime one of the tracked proxy objects updates. It returns
1923
* a cleanup function to stop the reactive effect from reevaluating.
@@ -34,6 +38,13 @@ export function watch(
3438
callback: WatchCallback,
3539
options?: WatchOptions,
3640
): Cleanup {
41+
if (import.meta.env?.MODE !== 'production' && !didWarnDeprecation) {
42+
console.warn(
43+
'[DEPRECATED] The `watch` util is no longer maintained. Please migrate to [valtio-reactive](https://github.com/valtiojs/valtio-reactive).',
44+
)
45+
didWarnDeprecation = true
46+
}
47+
3748
let alive = true
3849
const cleanups = new Set<Cleanup>()
3950

0 commit comments

Comments
 (0)