I want to track event from realtime database or can delay function in Js

82 Views Asked by At

I use responsiveVoice to call the que but when I want to call the same old que again it have no sound cause I push the same value to my realtime database in firebase that I subscribe to the static path.

But if I update to new value or something it will work again.

I try window.setTimeout to delete the old value before push it again but it doesn't work. Can I track that I pushing same value or ways to call que it again.

My source code look like . (I try to work in React)

class QueWait extends Component {
    constructor(props){
        super(props);
        this.state  = {
            ques: []
        };
        let app = this.props.db.database().ref('StockQ/1');
        app.on('value', snapshot => {
            this.getData(snapshot.val());
        });
    }

    getData(val) {

        let queValue =val;
        this.setState({
            ques: queValue
        });

        window.responsiveVoice.speak("Number" + queValue +"line up 
please.", "US English Female");

    }

My data base strcture. (Fire base)

  "Qnum" : 20,
  "StockQ" : {
  "1" : 15,
  "2" : 10,
  "Show" : 13,
  "stock" : 16
  }
0

There are 0 best solutions below