JSFiddle - React, Tailwind, and code Playground
by Varun Gupta
JavaScript
var Firebase = require('firebase');
var ref = new Firebase('<firebase-app>');
ref.child('queue/specs').set({
send_verification_code: {
start_state: 'send_verification_code',
in_progress_state: 'send_verification_code_in_progress'
},
verify_code: {
start_state: 'verify_code',
in_progress_state: 'verify_code_in_progress'
}
});
setTimeout(function() {
var request_id = ref.push().key();
ref.child('queue/tasks').push({
_state: 'send_verification_code',
mobile_number: '9999988888',
request_id: request_id
});
ref.child('responses/' + request_id).on('value', verify_code);
}, 1000);
function verify_code(snapshot) {
var data = snapshot.val();
console.log('Received response for send_verification_code request ', data);
setTimeout(function() {
var request_id = ref.push().key();
ref.child('queue/tasks').push({
_state: 'verify_code',
mobile_number: '9999988888',
request_id: request_id
});
ref.child('responses/' + request_id).on('value', verify_code_response);
}, 1000);
}
function verify_code_response(snapshot) {
console.log('Received response for verify_code request ', snapshot.val());
}