Git Product home page Git Product logo

Comments (4)

watdafox avatar watdafox commented on May 26, 2024

we use Q for that

from vibrant.js.

jariz avatar jariz commented on May 26, 2024

@watdafox Elaborate?

from vibrant.js.

watdafox avatar watdafox commented on May 26, 2024

Well, on our project, we use Q to make the entire process a promise.

  1. Call a custom function where vibrantjs does its magic (behind a Q.defer).
  2. Wait for the promise to be completed before continuing with vibrantjs data.

In application: https://git.popcorntime.io/popcorntime/desktop/blob/feature/materialDesign/src/app/lib/views/browser/item.js#L528

Line 528: getColor: function () { //let vibrantjs do stuff in a promise }; uses vibrantjs and Q.defer and it does w/e it wants.

Line 130, 203, 508: We call that 'getColor' function from elsewhere like this: this.getColor(true).then(function (color) { //do stuff when ready }); so we're sure to have the data when it's ready and not before.


Q is available here: https://github.com/kriskowal/q

A tool for creating and composing asynchronous promises in JavaScript

from vibrant.js.

jariz avatar jariz commented on May 26, 2024

Thanks for sharing.
Yea, there's many ways to do this async, there's a lot of promises libraries.
And to be honest, it's not that intensive of a calculation to begin with (takes a milisecond at max), so I don't really see the point of adding it to vibrant itself or something.
Answer to the initial question: use Q, or ES6 promises
Offtopic: @sv244 told me you guys were using vibrant, I think it's really cool, popcorn time is my favorite way to waste time!
If you have any questions, feel free to ask any time. (here or on twitter @jarizwarts)

from vibrant.js.

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.