File tree 1 file changed +7
-6
lines changed
packages/core/useSpeechRecognition
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -62,13 +62,11 @@ export function useSpeechRecognition(options: UseSpeechRecognitionOptions = {})
62
62
let recognition : SpeechRecognition | undefined
63
63
64
64
const start = ( ) => {
65
- if ( ! isListening . value )
66
- recognition ?. start ( )
65
+ isListening . value = true
67
66
}
68
67
69
68
const stop = ( ) => {
70
- if ( isListening . value )
71
- recognition ?. stop ( )
69
+ isListening . value = false
72
70
}
73
71
74
72
const toggle = ( value = ! isListening . value ) => {
@@ -119,8 +117,11 @@ export function useSpeechRecognition(options: UseSpeechRecognitionOptions = {})
119
117
recognition ! . lang = toValue ( lang )
120
118
}
121
119
122
- watch ( isListening , ( ) => {
123
- if ( isListening . value )
120
+ watch ( isListening , ( newValue , oldValue ) => {
121
+ if ( newValue === oldValue )
122
+ return
123
+
124
+ if ( newValue )
124
125
recognition ! . start ( )
125
126
else
126
127
recognition ! . stop ( )
You can’t perform that action at this time.
0 commit comments