Comments (4)
we use Q for that
from vibrant.js.
@watdafox Elaborate?
from vibrant.js.
Well, on our project, we use Q to make the entire process a promise.
- Call a custom function where vibrantjs does its magic (behind a Q.defer).
- 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.
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)
- CDN availability HOT 3
- new Vibrant() on <img style="display:none"> is a really bad idea HOT 2
- Black & white (grayscale?) image generates palette with colors HOT 6
- How to import Vibrant using jspm HOT 2
- [bug] global variable "index" HOT 4
- Demo not working in Safari or Firefox HOT 4
- Quality of zero does not let the loop proceed HOT 1
- Is License MIT? HOT 3
- Color does not look right HOT 1
- Vibrant.js + masterslider HOT 1
- Cross-origin image load denied by Cross-Origin Resource Sharing policy. HOT 1
- Incorrect Analysis HOT 1
- Gulpfile's compilerPath is hardcoded to a path that doesn't exist HOT 1
- Add possibility to save palette image HOT 1
- Cannot read property map of undefined HOT 3
- Imagem from div background HOT 3
- Unhandled rejection SecurityError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D' HOT 2
- Add mention to the algorithm used HOT 1
- Security dom exception on mobile ios (Both safari and chrome) HOT 1
- canvas added in the body HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vibrant.js.