javascript - infinite loop recursively with node.js -


i want loop through functions recursively after last function again goes first 1 , goes forever. can please me out on that? want know if there proper tutorial or me out solve these problem in node js looping , flow controlling. tried online tutorial though not able understand properly.

var util = require('util'); var async = require('async'); var sensortag = require('./index'); var use_read = true;  sensortag.discover(function(sensortag) {   console.log('discovered: ' + sensortag);    sensortag.on('disconnect', function() {     console.log('disconnected!');     process.exit(0);   });    async.series([   /*func 1*/       function(callback) {         console.log('connectandsetup');         sensortag.connectandsetup(callback);       },   /*func 2*/       function(callback) {         console.log('readdevicename');         sensortag.readdevicename(function(error, devicename) {           console.log('\tdevice name = ' + devicename);           callback();         });       },    /*func 3*/       function(callback) {         console.log('readsystemid');         sensortag.readsystemid(function(error, systemid) {           console.log('\tsystem id = ' + systemid);           callback();         });       }   })  }) 

when executed goes func 1 -> func 2 -> func 3 , hangs. need recursively loop these again , again.

edit code :i tried loop functions, not

var util = require('util'); var async = require('async'); var sensortag = require('./index'); var use_read = true;  sensortag.discover(function(sensortag) {   console.log('discovered: ' + sensortag);    sensortag.on('disconnect', function() {     console.log('disconnected!');     process.exit(0);   });  //function loop(){   async.series([   /*func 1*/       function(callback) {         console.log('connectandsetup');         sensortag.connectandsetup(callback);       },       function loop(callback){         /*func 2*/       function(callback) {         console.log('readdevicename');         sensortag.readdevicename(function(error, devicename) {           console.log('\tdevice name = ' + devicename);           callback();         });       },    /*func 3*/       function(callback) {         console.log('readsystemid');         sensortag.readsystemid(function(error, systemid) {           console.log('\tsystem id = ' + systemid);           callback();         });       },       function(callback){         loop()         callback()       }        } /*       function(callback) {         console.log('readdevicename');         sensortag.readdevicename(function(error, devicename) {           console.log('\tdevice name = ' + devicename);           callback();         });       },        function(callback) {         console.log('readsystemid');         sensortag.readsystemid(function(error, systemid) {           console.log('\tsystem id = ' + systemid);           callback();         });       },*/       /*func 4*/       loop();    ]); }    }) 

you can use forever function async, , inside call async.series


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -