File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
packages/core/useSpeechRecognition Expand file tree Collapse file tree 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 = {})
6262 let recognition : SpeechRecognition | undefined
6363
6464 const start = ( ) => {
65- if ( ! isListening . value )
66- recognition ?. start ( )
65+ isListening . value = true
6766 }
6867
6968 const stop = ( ) => {
70- if ( isListening . value )
71- recognition ?. stop ( )
69+ isListening . value = false
7270 }
7371
7472 const toggle = ( value = ! isListening . value ) => {
@@ -119,8 +117,11 @@ export function useSpeechRecognition(options: UseSpeechRecognitionOptions = {})
119117 recognition ! . lang = toValue ( lang )
120118 }
121119
122- watch ( isListening , ( ) => {
123- if ( isListening . value )
120+ watch ( isListening , ( newValue , oldValue ) => {
121+ if ( newValue === oldValue )
122+ return
123+
124+ if ( newValue )
124125 recognition ! . start ( )
125126 else
126127 recognition ! . stop ( )
You can’t perform that action at this time.
0 commit comments