Building an Operations object
The current operation that is being executed.
The input parameters to this string of operations
The list of operations that should be executed in sequence
the result from the operation
The full list of operation results
The current operation undo index.
In the event of an undo request, we will prepare a list that will be traversed to complete each undo function.
the callers operations complete callback
Optionally give a status message in your Operations object instead of letting the message from your sub-operations come through.
Accessor method to obtain all the files created using the file creator service
Accessor method to obtain all the files created that are marked as delete on undo
Get the operation name for display and other purposes
Accessor method for operation result
: The operation result
Append an additional message to the result message buffer
Determine if the operation failed
: If the operation failed
What percent complete is the Operations as a whole?s
percentComplete weighted against how many operations are complete
Accessor method for operation status
: The operation status/ stage name e.g. FAILED
Count the total number of base operation objects
Add a file created by the operation to the list of all files created and optionally mark this file as undoable, which will cause the undo operation to attempt to remove the file or directory.
Add a new operation to the list of operations to be executed.
Add the result to the end of the results list
Use this method to create files and optionally push them onto the files created stack that will be referenced when an undo is required.
Abstract method that must be implemented by the subclass. In this method, you invoke "addNextOperation" to add all the operations that must be performed when "executeOperation" is invoked.
This is a placeholder and is never directly called.
If more operations are available, execute the next operation in the list
Execute the next undo in the list. If the undo index is 0 when this function is called, then we can invoke the callers callback as all undos are complete.
The public interface to Operations. This method allows consumers to initiate the operation sequence.
: The operation results
Log that this is a set of operations that are about to begin.
Log that the set of operations have completed.
Callback invoked when the operation completes. Passed the result object of the operation.
The perform undo method sets that an attempt was made to perform the undo and invokes the undo method of the implemented operation.
Before invoking, any files that have been created and saved on the undo-able list will be cleaned.
Prepare a list of operations to 'undo', we will traverse the list calling the undo function of each operation. Only operations that are marked as 'undoa-able' will be called.
TODO - we could probably fire off all undo functions here async, but for now they are serial
Method to print all the files created by the file creator service.
If the operation decides that a different path is required. You can set the next operation to complete and whether or not you should continue down the original path
Set method to indicate that the operation failed.
Set the operation undo attempted (whether it succeed or failed is up to the undo method to set)
Set that the operation undo failed. This is for diagnostic purposes.
Set method to indicate that the operation is "undoable".
This means that if an operation fails, we will 'rollback' through the completed operations and undo any that have occurred.
Set the status message for the overall Operations object, which takes precedence over the sub-operations' messages
the message, including any templates you want replaced like %s or "{{myObject}}"
variable args as allowed by printf-like syntax or {myObject: this.myObject}
the final translated and formatted string (in case you want to log it etc.)
Perform all undos if the undo function is called for an Operations
Undo operation completed callback. Probably unnecessary.
Generated using TypeDoc
The Operations class extends Operation and is used to create a 'string' of operations that must be completed in serial order.
The implementing class is responsible (in defineOperations) for creating each operation (and invoking addNextOperation) to add the operations to the list. You must also call "defineOperations" from your constructor. This allows you to setup anything you need (in your constructor) before defining the list of operations.
You can initiate the operation by invoking performOperation, which will iterate through each operation defined and perform them in sequence. If a operation chooses to diverge, then