Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 7x 7x 6x 6x 6x 6x 6x | import { scope } from '../../constants'
/**
* You can stop watching a piece of code
* ```typescript
* import { State, Watch, unwatch } from '../..'
*
* const count = new State(0)
*
* new Watch(() => {
* console.log(unwatch(() => count.value++))
* })
*
* count.value++
* ```
* */
export function unwatch<T> (fn: () => T): T {
const { activeWatcher } = scope
scope.activeWatcher = undefined
const result = fn()
scope.activeWatcher = activeWatcher
return result
}
|