mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-12 04:10:36 +01:00
SynchronousDataTransaction commit() not marked @discardableResult #122
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @avaroam on GitHub (Jan 25, 2017).
Just thought I'd mention that the
commit()method ofSynchronousDataTransactionis not marked with@discardableResult, meaning it must currently be used like this:I'm not sure if this is intentional, but it seems like something that would often not be used, and in the read me it is used without
_ =Also, same is true of
commitAndWait()@JohnEstropia commented on GitHub (Jan 26, 2017):
This was intentional because the result should generally be handled. Incidentally
beginSynchronous()was made@discardableResultso that you can handle the result in one place. Maybe interchange the discardableResult attribute on those two methods?@avaroam commented on GitHub (Jan 26, 2017):
That makes sense! Having no discardable result on
commit()makes it consistent with async transactions. Just thought I'd mention it because it's written without_ =in the README.Out of curiosity, what would be the usual way to handle the
SaveResult? What would be a use case forhasChanges, and is it really worth checking theCoreStoreErrorfor all transactions? What would be a suitable course of action if an error did occur?@JohnEstropia commented on GitHub (Jan 27, 2017):
Since transactions produce
.successwhen there are no changes, thehasChangesis used when you need distinguish that case. This is useful in cases like data imports.Of course it is up to you and your app if you need to handle these results or not. The syntax just makes it clear that you explicitly chose to do it.
@avaroam commented on GitHub (Jan 27, 2017):
Nice. I've just been ignoring the result in most cases (if not all), but I can definitely see where it could be useful. Thanks for the insight!