Originally created by @yoiang on GitHub (Nov 4, 2015).
Hey @JohnEstropia !
I've just started using CoreStore and I'm excited!
I was wondering, are there were any plans to expose some sort of undo functionality similar to or using the NSUndoManager? Or can something similar be achieved already with Unsafe Transactions?
Thanks!
Originally created by @yoiang on GitHub (Nov 4, 2015).
Hey @JohnEstropia !
I've just started using CoreStore and I'm excited!
I was wondering, are there were any plans to expose some sort of undo functionality similar to or using the NSUndoManager? Or can something similar be achieved already with Unsafe Transactions?
Thanks!
@yoiang Thanks for the feedback!
If I remember correctly, the undoManager for all transactions should be intact, but direct access to the NSManagedObjectContext is currently not allowed on async and sync transactions. You are right that you can invoke undo operations on the UnsafeDataTransaction though!
lettransaction=CoreStore.beginUnsafe()// .. do some thingstransaction.internalContext.undo()
Can you share your use-case for needing undo operations? If I find enough demand for it I might enable it on all transaction classes as well.
@JohnEstropia commented on GitHub (Nov 5, 2015):
@yoiang Thanks for the feedback!
If I remember correctly, the `undoManager` for all transactions should be intact, but direct access to the `NSManagedObjectContext` is currently not allowed on async and sync transactions. You are right that you can invoke undo operations on the `UnsafeDataTransaction` though!
``` swift
let transaction = CoreStore.beginUnsafe()
// .. do some things
transaction.internalContext.undo()
```
Can you share your use-case for needing undo operations? If I find enough demand for it I might enable it on all transaction classes as well.
A use case I run into a fair bit is a View that visualizes a Model of some kind and let's say we provide a View and an Edit mode, during the life of the View the user may edit changes to the Model, press Cancel and undo all changes or undo particular changes, or press Done and have the changes committed.
Lemme know if I could be more specific or provide any more info.
@yoiang commented on GitHub (Nov 13, 2015):
Hey @JohnEstropia ! Sorry for the late response.
A use case I run into a fair bit is a View that visualizes a Model of some kind and let's say we provide a View and an Edit mode, during the life of the View the user may edit changes to the Model, press Cancel and undo all changes or undo particular changes, or press Done and have the changes committed.
Lemme know if I could be more specific or provide any more info.
@yoiang
Okay, I think UnsafeDataTransactions fits well for such cases. You should be able to implement this right now, but I'll add some utility methods to the transactions so we can save some typing :)
@JohnEstropia commented on GitHub (Nov 14, 2015):
@yoiang
Okay, I think `UnsafeDataTransaction`s fits well for such cases. You should be able to implement this right now, but I'll add some utility methods to the transactions so we can save some typing :)
@yoiang
Sorry, I just realized that the default NSUndoManager in iOS is nil, so you may need to create one and assign it to transaction.internalContext.undoManager. Another method is to recreate a new transaction with beginUnsafe() every time the user tries to undo all changes.
@JohnEstropia commented on GitHub (Nov 14, 2015):
@yoiang
Sorry, I just realized that the default `NSUndoManager` in iOS is `nil`, so you may need to create one and assign it to `transaction.internalContext.undoManager`. Another method is to recreate a new transaction with `beginUnsafe()` every time the user tries to undo all changes.
@JohnEstropia
Sounds good! If I notice a pattern with doing undo work with CoreStore that fits the CoreStore styling would you mind if I suggested a PR?
@yoiang commented on GitHub (Nov 14, 2015):
@JohnEstropia
Sounds good! If I notice a pattern with doing undo work with CoreStore that fits the CoreStore styling would you mind if I suggested a PR?
Sounds good! If I notice a pattern with doing undo work with CoreStore that fits the CoreStore styling would you mind if I suggested a PR?
I'd appreciate that! :)
@JohnEstropia commented on GitHub (Nov 14, 2015):
@yoiang
> Sounds good! If I notice a pattern with doing undo work with CoreStore that fits the CoreStore styling would you mind if I suggested a PR?
I'd appreciate that! :)
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 @yoiang on GitHub (Nov 4, 2015).
Hey @JohnEstropia !
I've just started using CoreStore and I'm excited!
I was wondering, are there were any plans to expose some sort of undo functionality similar to or using the NSUndoManager? Or can something similar be achieved already with Unsafe Transactions?
Thanks!
@JohnEstropia commented on GitHub (Nov 5, 2015):
@yoiang Thanks for the feedback!
If I remember correctly, the
undoManagerfor all transactions should be intact, but direct access to theNSManagedObjectContextis currently not allowed on async and sync transactions. You are right that you can invoke undo operations on theUnsafeDataTransactionthough!Can you share your use-case for needing undo operations? If I find enough demand for it I might enable it on all transaction classes as well.
@yoiang commented on GitHub (Nov 13, 2015):
Hey @JohnEstropia ! Sorry for the late response.
A use case I run into a fair bit is a View that visualizes a Model of some kind and let's say we provide a View and an Edit mode, during the life of the View the user may edit changes to the Model, press Cancel and undo all changes or undo particular changes, or press Done and have the changes committed.
Lemme know if I could be more specific or provide any more info.
@JohnEstropia commented on GitHub (Nov 14, 2015):
@yoiang
Okay, I think
UnsafeDataTransactions fits well for such cases. You should be able to implement this right now, but I'll add some utility methods to the transactions so we can save some typing :)@JohnEstropia commented on GitHub (Nov 14, 2015):
@yoiang
Sorry, I just realized that the default
NSUndoManagerin iOS isnil, so you may need to create one and assign it totransaction.internalContext.undoManager. Another method is to recreate a new transaction withbeginUnsafe()every time the user tries to undo all changes.@yoiang commented on GitHub (Nov 14, 2015):
@JohnEstropia
Sounds good! If I notice a pattern with doing undo work with CoreStore that fits the CoreStore styling would you mind if I suggested a PR?
@JohnEstropia commented on GitHub (Nov 14, 2015):
@yoiang
I'd appreciate that! :)