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 asDisposable convenience property to Task #205

Merged
merged 5 commits into from
Feb 20, 2024

Conversation

louisdebaere
Copy link
Contributor

Offers a convenient way to return Tasks as a Disposable instead of having to wrap it with AnonymousDisposable, for example in an EffectHandler

Example usage

extension LoadLyricsModelEffectHandler: EffectHandler {
    func handle(_ playbackData: PlaybackData, _ callback: EffectCallback<CardViewEvent>) -> Disposable {
        Task {
            do {
                let model = try await dataLoader.fetch(for: playbackData.track)
                callback.send(.receivedLyricsModel(model, for: playbackData))
            } catch {
                callback.send(.receivedError(for: playbackData))
            }
        }
        .asDisposable
    }
}

Offers a convenient way to return Tasks as a `Disposable` instead of having to wrap it with `AnonymousDisposable`, for example in an `EffectHandler`
Add copyright and documentation
Copy link
Collaborator

@zvonicek zvonicek left a comment

Choose a reason for hiding this comment

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

I noticed one more thing that's worth changing

MobiusCore/Source/Disposables/Task+Disposable.swift Outdated Show resolved Hide resolved
@louisdebaere
Copy link
Contributor Author

Pinging

@zvonicek zvonicek merged commit 8606126 into spotify:master Feb 20, 2024
2 checks passed
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