Giter Site home page Giter Site logo

wibosco / coalescingoperationsreducedboilerplate-example Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 28 KB

An example project to show how it's possible to coalesce NSOperation subclasses's callbacks with reduced boilerplate compared to previous examples

Home Page: https://williamboles.com/

License: MIT License

Swift 100.00%
nsoperation nsoperationqueue threading coalesce callback swift

coalescingoperationsreducedboilerplate-example's People

Contributors

tciuro avatar wibosco avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tciuro

coalescingoperationsreducedboilerplate-example's Issues

Couple of interesting requirements and design question

Thanks for the cool project, and the blog post.

Just wanted to let you know I had a couple of additional interesting requirements I would like to build on top of this:

  1. My network operation can either be user-initiated, e.g. from a pull-to-refresh, or background-initated, e.g. from a push notification. I would like to coalesce these but they have different NSOperation qualityOfService levels. I was thinking about trying to promote the QOS of an existing background operation if a subsequent user-initated operation is enqueued.

  2. If a network operation is part-way through then I don't want to coalesce another one, because new data might be available on the server to be downloaded. However if there is a part-way one, and another one, then the 3rd can be coalesced (since the 2nd hasn't even been started so no chance of missing anything).

  3. The operations I'll be coalescing have multiple progress blocks, not just completion.

Also I have a question about your design, why did you choose to the coalescing at the enqueuing of the new operation, rather than at the end of the old operation, e.g. at the last step to look into the queue and cancelling any queued operations that are the same as the one just ending. I thought it might be more thread-safe to do it inside an operation, but I suppose that's only if its a serial queue.

Any feedback on how to handle (or if to not bother about) these 3 requirements would be greatly appreciated! Thanks

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.