-
Notifications
You must be signed in to change notification settings - Fork 160
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-transactionshould 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:
-
Addtransaction type - when adding such a transaction one should not provideinitialValue. After successfully adding of such transaction it will be reflected in aggregated state likeAddtransaction type. If such a transaction is then added withDeletetransaction type it will be removed from aggregated state. Adding ofAddtransaction type with id which already exists in aggregated state will throw an exception; -
Updatetransaction type - when adding such a transaction one should provideinitialValue. After successfully adding of such transaction it will be reflected in aggregated state likeUpdatetransaction type. One can also updateAddtransaction type - this will be reflected in aggregated state likeAddtransaction type, as well asUpdatetransaction type - this will remain likeUpdatetransaction type in aggregated state. If one tries to updateDeletetransaction type an exception will be thrown. - Delete transaction type - when adding such a transaction one should provide
initialValue. After successfully adding of such transaction it will be reflected in aggregated state likeDeletedtransaction type. One can also deleteAddtransaction type, this will remove the record from the aggregated state. One can also deleteUpdatetransaction type, this will change the aggregated type toDelete. If one tries to deleteDeletetransaction 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.