Coder Social home page Coder Social logo

Comments (5)

npvisual avatar npvisual commented on May 27, 2024

Here's my code for reference :

let shortLinkMiddleware = EffectMiddleware<DynamicLinkAction, DynamicLinkAction, AppState, DynamicLinkComponents>.onAction { action, context, getState in
    let logger = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "ShortLinkMiddleware")
    switch action {
        case .generate:
            return .promise(
                token: "Any Hashable. Use this to cancel tasks, or to avoid two tasks of the same type",
                perform: { context, completionblock in
                    os_log(
                        "Creating new short link...",
                        log: logger,
                        type: .debug
                    )
                    let state = getState()
                    let api = context.dependencies
                    if let link = URL(string: state.invitationDeepLink),
                       let bundleid = state.bundleID {
                        api.link = link
                        api.domain = state.universalLinkBaseURL
                        api.options = DynamicLinkComponentsOptions()
                        api.options?.pathLength = .unguessable
                        api.iOSParameters = DynamicLinkIOSParameters(bundleID: bundleid)
                        
                        if let longDynamicLink = api.url {
                            DynamicLinkComponents.shortenURL(
                                longDynamicLink,
                                options: api.options,
                                completion: { url, warnings, error in
                                    if let url = url {
                                        completionblock(.response(url.absoluteString))
                                    } else {
                                        os_log(
                                            "Error shortening the URL from : %s",
                                            log: logger,
                                            type: .debug,
                                            String(describing: api.url)
                                        )
                                        completionblock(.error("Got an error while coverting short url"))
                                    }
                                }
                            )
                        } else {
                            completionblock(.error("Hmmm... No long URL available."))
                        }
                    } else {
                        os_log(
                            "Error converting the deep link or bundleid...",
                            log: logger,
                            type: .debug
                        )
                        completionblock(.error("Got an error while converting short url"))
                    }
                }
            )
        default: return .doNothing
    }
}

from swiftrex.

luizmb avatar luizmb commented on May 27, 2024

You are right. I didn't look yet with more time but it seems that https://github.com/SwiftRex/SwiftRex/blob/develop/Sources/CombineRex/Effect/Effect.swift#L191 is missing a @escaping clause before (OutputAction) -> Void argument of outer closure. Can you test it please and open PR if it solves? Then I can release tonight if PR is open.

CombineRex, RxSwiftRex and ReactiveSwiftRex, I couldn't find a way to write one single Effect to rule them all (yet), so there's a bit of duplication unfortunately.

from swiftrex.

luizmb avatar luizmb commented on May 27, 2024

Also here https://github.com/SwiftRex/SwiftRex/blob/develop/Sources/CombineRex/Effect/Effect.swift#L210

from swiftrex.

npvisual avatar npvisual commented on May 27, 2024

Seems to fix the compilation issue. Testing it out right now.

from swiftrex.

luizmb avatar luizmb commented on May 27, 2024

Ok, v0.8.1 Release created, pushing Pods right now.
PS: I had to merge develop into master because of some release script fixes.

from swiftrex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.