Coder Social home page Coder Social logo

Comments (7)

wenkesj avatar wenkesj commented on May 23, 2024

I'm not sure, I would have to look into it. Can you possibly record a .gif of the instance or provide a use case for me to test (some context of the code and platform you are using)? I assume this is due to a listener not being destroyed before the component is, as the callback is asynchronous.

from voice.

eggybot avatar eggybot commented on May 23, 2024

Sorry for no .gif,

Hi, when I use navigate to the function onSpeechResult to redirect to the next page

onSpeechResults(e) {
const { navigate } = this.props.navigation;
navigate('Result', {channelp:0, searchit: true, skeyword: keyvt});
}

but as I go back using navigation.goBack() , the error I mention which happen. But I notice that if the result page is within the current page and move to the other pages and goback, it didn't have any issue.

WHat Listner should I destroy?

thanks,

from voice.

wenkesj avatar wenkesj commented on May 23, 2024

I would do something similar to the example:

removeListeners() {
    const error = Voice.destroy();
    if (Voice.onSpeechStart != null) {
      Voice.onSpeechStart.remove();
      Voice.onSpeechStart = null;
    }
    if (Voice.onSpeechRecognized != null) {
      Voice.onSpeechRecognized.remove();
      Voice.onSpeechRecognized = null;
    }
    if (Voice.onSpeechEnd != null) {
      Voice.onSpeechEnd.remove();
      Voice.onSpeechEnd = null;
    }
    if (Voice.onSpeechError != null) {
      Voice.onSpeechError.remove();
      Voice.onSpeechError = null;
    }
    if (Voice.onSpeechResults != null) {
      Voice.onSpeechResults.remove();
      Voice.onSpeechResults = null;
    }
    if (Voice.onSpeechPartialResults != null) {
      Voice.onSpeechPartialResults.remove();
      Voice.onSpeechPartialResults = null;
    }
    if (Voice.onSpeechVolumeChanged != null) {
      Voice.onSpeechVolumeChanged.remove();
      Voice.onSpeechVolumeChanged = null;
    }
}

And before you navigate from the page or when the component is going to unmount:

onSpeechResults(e) {
  const { navigate } = this.props.navigation;
  this.removeListeners();
  navigate('Result', {channelp:0, searchit: true, skeyword: keyvt});
}

from voice.

eggybot avatar eggybot commented on May 23, 2024

got this error
Voice.onSpeechStart.remove is not a function

thanks,

from voice.

wenkesj avatar wenkesj commented on May 23, 2024

Ah, I see, I assumed wrong. Try doing this:

removeListeners() {
  Voice.destroy();
}

The listeners are removed in the Voice.destroy() method.

from voice.

eggybot avatar eggybot commented on May 23, 2024

Now, its working. Thanks

from voice.

JohnBlazek avatar JohnBlazek commented on May 23, 2024

Just a heads up, you may want to update VoiceTest to reflect this change. Great stuff, BTW.

from voice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.