Latest 0.1.1
Homepage https://github.com/1amageek/AssemblyLine
License MIT
Platforms ios 10.0
Authors

Version
[Platform]()

AssemblyLine processes several tasks continuously in the background.
Discard tasks that failed during execution during execution.

Usage 👻

Take example of Tesla’s factory.

Define Status.

enum ModelXStatus: StatusProtocol {
    case spec
    case assembly
    case paint
}

Define Error.

enum ModelXError: Error {
    case invalid
}

Processable protocol.

class ModelX: Processable {

    typealias Status = ModelXStatus

    var error: Error?
    var id: String
    var status: Status
    var workItem: DispatchWorkItem?
    var isAssembled: Bool = false
    var color: UIColor?

    init() {
        self.id = UUID().uuidString
        self.status = .spec        
    }

    // Processing when an error occurs
    func dispose(_ error: Error?) {

    }
}
struct ModelXPackage: Packageable {
    var products: [ModelX]
}
// Define workflow steps
let assembly: Step<ModelX> = Step({ (product) -> ModelX in
    product.isAssembled = true
    return product
})

// Define workflow steps
let paint: Step<ModelX> = Step({ (product) -> ModelX in
    product.color = .white
    return product
})

// Making a manufacturing line to do workflow
let line: Line<ModelX, ModelXPackage> = Line(workflow: [assembly, paint])

// Generate 10 ModelX
(0..<10).forEach({ (index) in
    let product: ModelX = ModelX()
    line.generate(product)
})

// Packaging
line.packing { (products, isStopped) in    
    if isStopped {
        print("Line is stopped")
        return
    }
    let package = ModelXPackage(products: products)
}

Latest podspec

{
    "name": "AssemblyLine",
    "version": "0.1.1",
    "summary": "AssemblyLine is a library for easily writing workflows.",
    "description": "AssemblyLine processes several tasks continuously in the background.nDiscard tasks that failed during execution during execution.",
    "homepage": "https://github.com/1amageek/AssemblyLine",
    "screenshots": "https://github.com/1amageek/AssemblyLine/blob/master/AssemblyLine.png",
    "license": {
        "type": "MIT",
        "file": "https://github.com/1amageek/AssemblyLine/blob/master/LICENSE"
    },
    "authors": {
        "1amageek": "[email protected]"
    },
    "social_media_url": "http://twitter.com/1amageek",
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/1amageek/AssemblyLine.git",
        "tag": "0.1.1"
    },
    "source_files": [
        "AssemblyLine",
        "AssemblyLine/**/*.{swift}"
    ],
    "pushed_with_swift_version": "3.1"
}

Pin It on Pinterest

Share This