Created
January 22, 2022 20:35
-
-
Save lucas-moraes/9f476392918413a1c27cbe981c073071 to your computer and use it in GitHub Desktop.
Javascript Trigger (meta queue) for lazy refresh of SQLITE return
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let index = 0; | |
const Trigger = ( int ) => { | |
index = index + int; | |
if ( index < $scope.group.length ) //$scope.group - lista de arrays para serem enviados | |
{ | |
/* | |
DataSourse é o arquivo com o serviço $http.post(), | |
nesse caso o response é o int da ultima rowId adicionada. | |
*/ | |
dataSource.addConjunto( $scope.group[item-A], $scope.group[item-B], $scope.group[item-C] ) | |
.then( ( res ) => { | |
//Se o response for 0 é sinal que backend não aceitou o post. | |
if ( res.data <= 0 ) | |
{ | |
console.log( res ); | |
} | |
//Adiciona um numero ao Index... | |
else | |
{ | |
Trigger( 1 ); | |
} | |
} ); | |
} | |
}; | |
//Primeira chamada com o index 0 | |
Trigger( index ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment