thoaded

Thoaded

Library for simple and fast design pattern that extends model, view and controller for asynchronous events in supported modern programming languages.

Installation

You should ensure that you add the router as a dependency in your swift project:

.package(url: "https://github.com/walberbeltrame/thoaded.git", from: "0.1.0")

Documentation

Thoaded applications are created by composing a series of simple inheritances. By convention, this components extends Modify-based Asynchronous Pattern.

extension String : Task {}

extension Thoaded where T == String {

    func added(_ text: String) -> Task {
        return text
    }

    func updated(_ text: String) -> Task {
        return text
    }

    func deleted(_ text: String) -> Task {
        return text
    }

    func readed(_ text: String) -> Task {
        return text
    }

    func queried(_ texts: String...) -> [Task] {
        return [String]()
    }

    func listened(_ texts: String...) -> Task {
        return String()
    }

    func unlistened(_ texts: String...) -> Task {
        return String()
    }

}

class SampleModified : Modified, Thoaded {

    typealias T = String

}

class SampleModeled : Modeled {

    typealias T = String

    var modified = SampleModified()

}

class SampleViewed : Viewed {

    typealias T = String

    var modified = SampleModified()

}

class SampleControlled : Controlled {

    var modeled = SampleModeled()
    var viewed = SampleViewed()

    init() {
        // dispatch read event in modeled listener
        var text = self.modeled.readed("Hello, World!") as! String
        // dispatch read event to viewed listener
        text = self.viewed.readed(text) as! String
        // print successfully 
        print("Print \(text) successfully.")
    }

}

Asynchronous

Adapt codes to use with frameworks like PromiseKit or Google Promise.

Linux

Swift builds are not available on the Linux environments for current Travis. Install Swift manually after downloading and run test with command.

swift test

Compatibility

Thoaded supports all environments that are Swift 5.