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 25 | 23x 23x 438x 7x 7x 431x | import { warn, watch } from 'vue'; /** * Throw a warning when a condition becomes true, but only once. * * This watches the condition function, and throws a warning when it returns true for the first * time. After that, it stops watching the condition, so that the warning is only thrown once. * * @param shouldWarn Condition to watch. When this returns true, the warning is thrown. * @param message Warning message */ export default function useWarnOnce( shouldWarn: () => boolean, message: string ): void { if ( shouldWarn() ) { warn( message ); return; } const stop = watch( shouldWarn, ( newValue ) => { Iif ( newValue ) { warn( message ); stop(); } } ); } |