Skip to content

onDrop #1212

Answered by JaapWijnen
JaapWijnen asked this question in Q&A
Discussion options

You must be logged in to vote

For anyone interested! Got it working by making the following environment client:

public struct OnDropImageClient {
    public struct OnDropError: Error, Equatable { }
    
    var onDrop: ([NSItemProvider]) -> Effect<NSImage, OnDropError>
    
    public static let noop = Self(
        onDrop: { _ in .none }
    )
    
    public static let live = Self(
        onDrop: { providers in
            Effect<NSImage, OnDropError>.future { callback in
                providers.first?.loadDataRepresentation(
                    forTypeIdentifier: "public.file-url",
                    completionHandler: { (data, error) in
                        if
                            let data,

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JaapWijnen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant