Coder Social home page Coder Social logo

taskmanager's Introduction

Shakuro Task Manager

Task Manager

Version Platform License 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 11.0+
  • Xcode 11.0+
  • Swift 5.0+

Installation

CocoaPods

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

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 subclassing BaseOperation. An operation should be a complete and independent unit of business logic.
  2. Subclass TaskManager and override .willPerformOperation(). Define dependencies between operations in this method. It’s a good idea to create two separate TaskManager 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() on TaskManager. You can use completions to handle results.

Have a look at the TaskManager_Example

Important notes

An operation should have operationHash 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 a retryHandler 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

Star this tool if you like it, it will help us grow and add new useful things. Feel free to reach out and hire our team to develop a mobile or web project for you.

taskmanager's People

Contributors

apopov1988 avatar eugendevios avatar sanakabarabaka avatar sergeyyypopov avatar slaschukshakuro avatar spopovshakuro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.