- Notifications
You must be signed in to change notification settings - Fork0
Manager of different background tasks
License
shakurocom/TaskManager
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Task Manager is a Swift library designed to manage asynchronous operations. The main purpose of the Task Manager component is to encapsulate work with the server, database, and other background operations into unit-like operations or tasks. This helps to separate business logic from UI and reuse operations across the app.
- iOS 13.0+
- Xcode 15.0+
- Swift 5.0+
To integrate Task Manager into your Xcode project with CocoaPods, specify it in yourPodfile:
pod'Shakuro.TaskManager'
Then, run the following command:
$ pod install
If you prefer not to use CocoaPods, you can integrate Shakuro.TaskManager simply by copying it to your project.
- Create a couple of operations by subclassing
BaseOperation. An operation should be a complete and independent unit of business logic. - Subclass
TaskManagerand override.willPerformOperation(). Define dependencies between operations in this method. It’s a good idea to create two separateTaskManagerobjects/subclasses: one to handle auth-related tasks and the second one for all other work. - Start your tasks by calling
.performOperation()or.performGroup()onTaskManager. You can use completions to handle results.
Have a look at theTaskManager_Example
An operation should haveoperationHash defined if its work rely only on its options. Hash is used in.willPerformOperation() to construct dependencies.
Carefully consider the dependencies between operations..willPerformOperation() should return an already existing in the queue (old) operation instead of a new one if both operations (old & new) are equal from the business logic perspective. This will result in only single operation being executed with multiple completion callbacks.
Each task (an operation or a group of operations) can have aretryHandler to perform a retry under specified conditions. It is a perfect tool if you are dealing with an unreliable server.
Usual flow: Interactor -> Options -> Task Manager (operations + dependencies inside) -> HTTP Client + Database -> Retry if error (for example session expired error) -> Completion block inside Interactor with typed result.
Shakuro.TaskManager is released under the MIT license.See LICENSE for details.
Explore our expertise inNative Mobile Development andiOS Development.
If you need professional assistance with your mobile or web project, feel free tocontact our team
About
Manager of different background tasks
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors7
Uh oh!
There was an error while loading.Please reload this page.

