Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UIView.later... #164

Merged
merged 7 commits into from
Aug 27, 2020
Merged

Add UIView.later... #164

merged 7 commits into from
Aug 27, 2020

Conversation

0xLeif
Copy link
Member

@0xLeif 0xLeif commented Aug 26, 2020

UIView.later POC

Example Usage

import UIKit
import SwiftUIKit
import LaterView

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.embed {
            UIView.later { later in
                later
                    .fetch(url: URL(string: "https://jsonplaceholder.typicode.com/todos/1")!)
                    .flatMap { data, response, error in
                        if let error = error {
                            return later.main {
                                VStack {
                                    [
                                        Image(.red),
                                        Label("Error: \(error)")
                                    ]
                                }
                            }
                        }
                        
                        guard let data = data else {
                            return later.main {
                                List(defaultCellHeight: 256) {
                                    [
                                        Label("Response: \(String(describing: response))")
                                            .number(ofLines: 100)
                                    ]
                                }
                            }
                        }
                        
                        return later.main {
                            Label("\(String(data: data, encoding: .utf8) ?? "-1")")
                                .number(ofLines: 10)
                                .padding()
                        }
                }
            }
        }
    }
}

@0xLeif 0xLeif added the enhancement New feature or request label Aug 26, 2020
@0xLeif 0xLeif requested review from ambid17 and Oschly August 26, 2020 13:11
@0xLeif 0xLeif self-assigned this Aug 26, 2020
@0xLeif 0xLeif merged commit 33db9d7 into develop Aug 27, 2020
@0xLeif 0xLeif deleted the feature/later-view branch August 27, 2020 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants