Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.
/ Combino Public archive

🔮 Combine async extensions using DispatchQueue

Notifications You must be signed in to change notification settings

0xLet/Combino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Combino

⚠️ Development has been moved to Task

promise

promise<T>(work: @escaping (@escaping Future<T, Error>.Promise) -> Void) -> Future<T, Error>

promise(work: @escaping (@escaping Future<Void, Error>.Promise) -> Void) -> Future<Void, Error>

do

do<T>(withDelay delay: UInt32 = 0,
                               work: @escaping () throws -> T) -> Future<T, Error>

do(withDelay delay: UInt32 = 0,
                            work: @escaping () throws -> Void = {}) -> Future<Void, Error>

main

main<T>(withDelay delay: UInt32 = 0,
                               work: @escaping () throws -> T) -> Future<T, Error>

main(withDelay delay: UInt32 = 0,
                            work: @escaping () throws -> Void = {}) -> Future<Void, Error>

fetch

fetch(url: URLRequest) -> Future<(Data?, URLResponse?), Error>

fetch(url: URL) -> Future<(Data?, URLResponse?), Error>

post

post(request: URLRequest) -> Future<(Data?, URLResponse?), Error>

post(url: URL, withData data: (() -> Data)? = nil) -> Future<(Data?, URLResponse?), Error>

Combino Examples

.sink(SinkEvent)

Combino
    .do(withDelay: 5)
    .sink(.success { someFunction() })
    .store(in: &bag)

.sink(() -> [SinkEvent])

Combino
    .do(withDelay: 5) {
        "Hello World!"
}
.sink {
    [
        .completion {
            sema.signal()
        },
        .success { value in
            XCTAssertEqual(value, "Hello World!")
        },
        .failure { _ in
            XCTAssert(false)
        }
    ]
}
.store(in: &bag)