-
Notifications
You must be signed in to change notification settings - Fork 161
Transaction specification
Version | User | Date | Notes |
---|---|---|---|
0.1 | Milko Venkov | Aug 30, 2018 | Initial Draft |
0.2 | Milko Venkov | Sep 04, 2018 | Transaction state |
igx-transaction
should be able to plug between given component and its data source. While plugged in igx-transaction
should collect all the transactions performed in the component without send them to the data source. igx-transaction
should be able to update the data source and commit all the transactions when needed.
- there is no end users stories as
igx-transaction
should be an Angular Service.
- be able to enable transaction on a given component
- be able to retrieve all the transactions - transaction log
- be able to get updated state of the data including all transactions in the transaction log
- be able to update data source with all the transactions currently in the transaction log
- be able to undo the last change
- be able to redo the change that was undone
- be able to reset all the transactions in the transaction log
3.1. End User Experience
3.2. Developer Experience
Developers are able to inject the igx-transaction
service. Then developers should be able to add transaction to the transaction log. After some transactions are added developers should be able to retrieve updated data source state, including all transactions in the transaction log; update the data source when needed; reset all the transactions in the transaction log; perform undo and redo actions.
Here is what will happen with transaction state when new transactions is added:
-
Add
transactions type - when adding such a transactions one should not provideinitialValue
. After successfully adding of such transactions it will be reflected in aggregated state likeAdd
transactions type. If such a transactions is then added withDelete
transactions type it will be removed from aggregated state. Adding ofAdd
transaction type with id which already exists in aggregated state will throw an exception; -
Update
transactions type - when adding such a transactions one should provideinitialValue
. After successfully adding of such transactions it will be reflected in aggregated state likeUpdate
transactions type. One can also updateAdd
transactions type - this will be reflected in aggregated state likeAdd
transactions type, as well asUpdate
transactions type - this will remain likeUpdate
transactions type in aggregated state. If one tries to updateDelete
transactions type an exception will be thrown. - Delete transactions type - when adding such a transactions one should provide
initialValue
. After successfully adding of such transactions it will be reflected in aggregated state likeDeleted
transaction type. One can also deleteAdd
transaction type, this will remove the record from the aggregated state. One can also deleteUpdate
transaction type, this will change the aggregated type toDelete
. If one tries to deleteDelete
transaction type an exception will be thrown.
Here is visual representation of all possible transactions paths.
3.3. API
ITransaction
Name | Description | Parameters |
---|---|---|
add | Adds provided transaction with originalValue if any | transaction, originalValue |
getLastTransactionById | Returns last transaction related to the passed id | id |
getTransactionLog | Returns an array of all transactions | - |
undo | Remove the last transaction if any | - |
redo | Applies the last undone transaction if any | - |
currentState | Returns a map of actual state for each changed item | - |
update | Applies all changes for all changed items in the provided data | data |
reset | Clears all transactions | - |
There are no any assumptions or limitations.