Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Manager of different background tasks

License

NotificationsYou must be signed in to change notification settings

shakurocom/TaskManager

Repository files navigation

Shakuro Task Manager

Task Manager

VersionPlatformLicense MIT

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.

Requirements

  • iOS 13.0+
  • Xcode 15.0+
  • Swift 5.0+

Installation

CocoaPods

To integrate Task Manager into your Xcode project with CocoaPods, specify it in yourPodfile:

pod'Shakuro.TaskManager'

Then, run the following command:

$ pod install

Manually

If you prefer not to use CocoaPods, you can integrate Shakuro.TaskManager simply by copying it to your project.

Usage

  1. Create a couple of operations by subclassingBaseOperation. An operation should be a complete and independent unit of business logic.
  2. SubclassTaskManager and override.willPerformOperation(). Define dependencies between operations in this method. It’s a good idea to create two separateTaskManager objects/subclasses: one to handle auth-related tasks and the second one for all other work.
  3. Start your tasks by calling.performOperation() or.performGroup() onTaskManager. You can use completions to handle results.

Have a look at theTaskManager_Example

Important notes

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.

License

Shakuro.TaskManager is released under the MIT license.See LICENSE for details.

Give it a try and reach us

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

Stars

Watchers

Forks

Packages

No packages published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp