Skip to content

Instantly share code, notes, and snippets.

@Mreyna3
Last active May 26, 2019 20:49
Show Gist options
  • Save Mreyna3/e5e79b8159f2bda3d8d2c0516e7d23a0 to your computer and use it in GitHub Desktop.
Save Mreyna3/e5e79b8159f2bda3d8d2c0516e7d23a0 to your computer and use it in GitHub Desktop.
addToBatch
private func addToBatch(transaction: Double) {
// 1
queue.enqueue(element: transaction)
//2
batchSum += transaction
if(shouldProcessBatch()){
// 3
processBatch()
}else{
// 4
defaults.set(batchSum, forKey: "batch_sum")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment