Originally created by @mrichtsfeld on GitHub (Nov 28, 2016).
I need to use UnsafeDataTransaction for editing in some views. I change values from the UI which get stored to the object within the transaction. However the UnsafeDataTransaction uses its own queue. When working with CoreData without CoreStore it is necessary to edit an object with the queue of its NSManagedObjectContext via:
myObject.managedObjectContext?.performAndWait { // do your changes here }
I haven't found anything to do that on the UnsafeDataTransaction. Is it intended do be done via performAndWait on the managed object's context, or directly on the UnsafeDataTransaction? If there is any implementation necessary to do this I can fork and do it. I only want to discuss the right way to do it.
Btw. great framework, keep up the good work 👍
Originally created by @mrichtsfeld on GitHub (Nov 28, 2016).
I need to use `UnsafeDataTransaction` for editing in some views. I change values from the UI which get stored to the object within the transaction. However the `UnsafeDataTransaction` uses its own queue. When working with CoreData without CoreStore it is necessary to edit an object with the queue of its `NSManagedObjectContext` via:
`myObject.managedObjectContext?.performAndWait {
// do your changes here
}`
I haven't found anything to do that on the `UnsafeDataTransaction.` Is it intended do be done via `performAndWait` on the managed object's context, or directly on the `UnsafeDataTransaction`? If there is any implementation necessary to do this I can fork and do it. I only want to discuss the right way to do it.
Btw. great framework, keep up the good work :+1:
The UnsafeDataTransaction inherits a queue from BaseDataTransaction, but it never uses it. Using UnsafeDataTransactions means you explicitly want to bypass CoreStore's queueing mechanism.
While I recommend you use AsynchronousDataTransactions or SynchronousDataTransactions instead, if you really need to go without queueing then you are free to edit objects directly (at your discretion) or use Core Data's standard perform methods.
@JohnEstropia commented on GitHub (Nov 28, 2016):
The UnsafeDataTransaction inherits a queue from BaseDataTransaction, but it **never** uses it. Using UnsafeDataTransactions means you explicitly want to bypass CoreStore's queueing mechanism.
While I recommend you use AsynchronousDataTransactions or SynchronousDataTransactions instead, if you really need to go without queueing then you are free to edit objects directly (at your discretion) or use Core Data's standard `perform` methods.
Thanks for your quick answer and the clarification on the perform methods.
Regarding the AsynchronousDataTransactions or SynchronousDataTransactions I would also prefer using these, but in my case I pass an object to a view for editing within an UnsafeDataTransaction. As soon as editing is finished I save/commit it. Maybe there is something I missed, but as far as I understand this cannot we accomplished either by synchronous or asynchronous data transaction, right? The first one is anyway using the current thread to do the work and the second uses a background queue, but there is still no way to keep it open for a while and commit it at the end, right?
@mrichtsfeld commented on GitHub (Nov 28, 2016):
Thanks for your quick answer and the clarification on the `perform` methods.
Regarding the AsynchronousDataTransactions or SynchronousDataTransactions I would also prefer using these, but in my case I pass an object to a view for editing within an UnsafeDataTransaction. As soon as editing is finished I save/commit it. Maybe there is something I missed, but as far as I understand this cannot we accomplished either by synchronous or asynchronous data transaction, right? The first one is anyway using the current thread to do the work and the second uses a background queue, but there is still no way to keep it open for a while and commit it at the end, right?
I see, yes UnsafeDataTransaction is a good use for this. If so, as long as there is no other transactions working on the same data while the UnsafeDataTransaction is in use then there shouldn't be a need to worry about performBlock methods.
@JohnEstropia commented on GitHub (Nov 28, 2016):
I see, yes UnsafeDataTransaction is a good use for this. If so, as long as there is no other transactions working on the same data while the UnsafeDataTransaction is in use then there shouldn't be a need to worry about performBlock methods.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @mrichtsfeld on GitHub (Nov 28, 2016).
I need to use
UnsafeDataTransactionfor editing in some views. I change values from the UI which get stored to the object within the transaction. However theUnsafeDataTransactionuses its own queue. When working with CoreData without CoreStore it is necessary to edit an object with the queue of itsNSManagedObjectContextvia:myObject.managedObjectContext?.performAndWait { // do your changes here }I haven't found anything to do that on the
UnsafeDataTransaction.Is it intended do be done viaperformAndWaiton the managed object's context, or directly on theUnsafeDataTransaction? If there is any implementation necessary to do this I can fork and do it. I only want to discuss the right way to do it.Btw. great framework, keep up the good work 👍
@JohnEstropia commented on GitHub (Nov 28, 2016):
The UnsafeDataTransaction inherits a queue from BaseDataTransaction, but it never uses it. Using UnsafeDataTransactions means you explicitly want to bypass CoreStore's queueing mechanism.
While I recommend you use AsynchronousDataTransactions or SynchronousDataTransactions instead, if you really need to go without queueing then you are free to edit objects directly (at your discretion) or use Core Data's standard
performmethods.@mrichtsfeld commented on GitHub (Nov 28, 2016):
Thanks for your quick answer and the clarification on the
performmethods.Regarding the AsynchronousDataTransactions or SynchronousDataTransactions I would also prefer using these, but in my case I pass an object to a view for editing within an UnsafeDataTransaction. As soon as editing is finished I save/commit it. Maybe there is something I missed, but as far as I understand this cannot we accomplished either by synchronous or asynchronous data transaction, right? The first one is anyway using the current thread to do the work and the second uses a background queue, but there is still no way to keep it open for a while and commit it at the end, right?
@JohnEstropia commented on GitHub (Nov 28, 2016):
I see, yes UnsafeDataTransaction is a good use for this. If so, as long as there is no other transactions working on the same data while the UnsafeDataTransaction is in use then there shouldn't be a need to worry about performBlock methods.
@mrichtsfeld commented on GitHub (Nov 28, 2016):
Great, thanks for you help and clarifications 👍