Code Monkey home page Code Monkey logo

Comments (7)

seanhenry avatar seanhenry commented on May 24, 2024 1

I've uploaded a release which no longer calls empty closures automatically. I've also made steps towards supporting customised mock templates as we discussed earlier which will allow you create your own template to capture closures if you like. Stay tuned for that feature.

from swiftmockgeneratorforxcode.

seanhenry avatar seanhenry commented on May 24, 2024

Hi. Thanks for raising this issue. I can definitely see why you don’t want to always call the closure now, especially with this example. How would you feel about having a Bool when a closure has no arguments?

var shouldInvokeSetOnSuccess = false

And then inside the method:

if shouldInvokeSetOnSuccess {
  onSuccess()
}

from swiftmockgeneratorforxcode.

LeonidKokhnovich avatar LeonidKokhnovich commented on May 24, 2024

Thanks for looking into it! The flag would definitely help.

I would try to follow the existing convention like:

...
var stubbedSetOnSuccessResult: (Void)?
...
if let result = stubbedSetOnSuccessResult {
            _ = onSuccess?()
        }

but if there is no parameter needed, that might be confusing...

from swiftmockgeneratorforxcode.

seanhenry avatar seanhenry commented on May 24, 2024

I think I'm leaning towards using the Bool even though it breaks the existing convention. I think it will be easier to understand that way. I'm planning to look at this issue next :)

from swiftmockgeneratorforxcode.

LeonidKokhnovich avatar LeonidKokhnovich commented on May 24, 2024

@seanhenry The other option is not to call blocks automatically but instead store the block in the params list. That introduces a requirement to clean up the memory, but also might be worth considering.

from swiftmockgeneratorforxcode.

seanhenry avatar seanhenry commented on May 24, 2024

We have to give the option to call the closures automatically because it needs to support non-escaping closures but I can definitely see the benefit of storing the escaping closures. And you’re right with the potential memory issues. You would likely have to set the mock to nil in the tear down which isn’t ideal. I think this might need some more thought.

from swiftmockgeneratorforxcode.

LeonidKokhnovich avatar LeonidKokhnovich commented on May 24, 2024

Great, thanks a lot!

from swiftmockgeneratorforxcode.

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.