Git Product home page Git Product logo

Comments (4)

shoumikhin avatar shoumikhin commented on April 28, 2024

Hi @umbri,

The thing is ‘all’ and other extensions do not control the order in which the promises get resolved, nor run them either, but just wait for them. There’s even no guarantees if promises passed to ‘all’ will all be resolved on a concurrent queue simultaneously. It totally depends on how you created those promises and on which queue would you invoke the block which will eventually trigger ‘fulfill’ or ‘reject’ with a particular promise. The following discussion may also be helpful: #28 (comment)

Let us know if there’s anything still unclear, happy to elaborate.

Thanks.

from promises.

 avatar commented on April 28, 2024

Hi @shoumikhin

Thank you for a quick reply,

About my proposal,
I was sure that promise is not executed till you call .then on it, but after some tests I find my epic broken logic :)

  1. If above is true, then my proposal is useless
  2. If above is true, then I have one more question :)

How to create Promise like a closure, that will do something after invoke it example:

let closure = {
    print("I am closure")
}

... 

closure()
let promise = Promise {
    print("I am promise")
}

...

// only now it will be executed 
promise.then {

}

from promises.

 avatar commented on April 28, 2024

I think something like this will be a nice feature: https://github.com/mxcl/PromiseKit/blob/master/Sources/when.swift#L104

from promises.

shoumikhin avatar shoumikhin commented on April 28, 2024

I don't think anything like that would be possible, because then just subscribes as an observer for a promise state and has no side-effects on the promise behavior, like triggering some work blocks associated with the promise. Plus, there're actually no such blocks that a promise keeps that can be somehow invoked later, to begin with.

Promise is an extremely small and simple abstraction. I imagine you could build something more sophisticated on top of it to allow such "cold" subscription. But there're no plans to overcomplicate the existing lib at the moment.

from promises.

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.