镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Introduce @Publish<Modifier> resultBuilder to create Combine Publisher - #6

Open
pauljohanneskraft wants to merge 1 commit into
mainfrom
publish
Open

pauljohanneskraft wants to merge 1 commit into
mainfrom
publish

Conversation

@pauljohanneskraft

@pauljohanneskraft pauljohanneskraft commented May 4, 2021 •

Copy link
Copy Markdown
Contributor

This change introduces a new result builder to allow for the simple creation of reactive APIs.

One will be able to create publishers using the following:

@Publish<MainQueue>
func fetchProject(name: String) -> Pipeline<Project> {
    if let project = cache[name] {
        project
    } else {
        URLSession.shared.dataTaskPublisher(for: request)
            .map(\.data)
            .decode(Project.self, from: JSONDecoder())
    }
}

@@ -0,0 +1,80 @@
//
// File.swift

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix file name.

@@ -0,0 +1,33 @@
//
// File.swift

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix file name.


public static func buildEither<P: Publisher>(second component: P) -> P {
component
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of the above two functions? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants