Skip to content

Instantly share code, notes, and snippets.

@lucas-moraes
Created January 22, 2022 20:35
Show Gist options
  • Save lucas-moraes/9f476392918413a1c27cbe981c073071 to your computer and use it in GitHub Desktop.
Save lucas-moraes/9f476392918413a1c27cbe981c073071 to your computer and use it in GitHub Desktop.
Javascript Trigger (meta queue) for lazy refresh of SQLITE return
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