Comments (8)
One option for angular 1 projects would be to use the bluebird promise library. It exposes its scheduler which can then be tied to angular's digest cycle effciently.
The angular-bluebird-promises library takes care of the integration and replaces the $q service implementation with the bluebird implementation for you.
from legacy-ionic-cloud.
@meticoeus what is the advantage of using bluebird over the builtin $q?
Currently I wrap the promises with $q.all([promise])
, but I'm not sure why... I should test $q.when(promise)
instead, since that seems to be the preferred way to do it.
from legacy-ionic-cloud.
I guess bluebird adds more features? We don't need the additional features and I'd rather not have another dependency included in our bundle. We should be able to make use of $q
to wrap our promises.
from legacy-ionic-cloud.
An option for a user of the library is to replace the global Promise from es6-promises (or native implementation) with bluebird promises. All uses of Promise in this and other libraries and your app code will be using a single implementation that can now inter-op with the digest cycle. You can then use the API directly instead of the wrapped versions, which may make sense in a project that is being migrated to angular 2. Just import ionic-cloud in the normal way.
from legacy-ionic-cloud.
Oh, I see! That native implementation replacement and digest cycle hook-in is something I've been wondering about. An option would be to document how to set up that library in Ionic 1 projects. We can't depend on it because our client must work for angular 1, Angular 2, and non-angular projects.
I personally think just wrapping the promises with angular's $q
would be better because it's an api that angular devs are familiar with. It just seems more consistent. That way things work out of the box and we wouldn't need to require users to set up an additional library.
from legacy-ionic-cloud.
The $q
wrapper approach is probably the best way to go to keep things simple and familiar for ng1 devs.
Documenting that you can and how setup bluebird so that you can avoid the wrapper might be useful for anyone doing a 1->2 migration so they can use the library directly without the ng1 modules.
from legacy-ionic-cloud.
For reference to anyone considering this strategy, there was already a discussion about making bluebird usable in angular 2 before they dropped $q for native promises.
The main take away is that $q is silent about uncaught promise rejections while bluebird is not. Some ng1 libraries like ui-router are guilty of this so your console will blow up until you change bluebird's configuration. Of course, that feature is useful when reviewing your own code.
from legacy-ionic-cloud.
@meticoeus @Maistho Got this working! If window.Promise
is undefined, set it to $q
, otherwise patch our use of promises with $q.when
. π
from legacy-ionic-cloud.
Related Issues (20)
- ionic v1 - facebook authentication class is invalid HOT 1
- iOS build stuck in "Building" status HOT 3
- Push notification changes HOT 1
- Ionic push notification doesnβt work when app is closed HOT 1
- build for prod fails
- Security Profile docs need updating
- "ionic io init" do not work HOT 1
- IOS - Failure while building the project environment HOT 3
- CallNumber plugin throwing error: "plugin_not_installed" after uploading build to cloud.
- Ionic V3 . No messages associated to a Notification HOT 1
- Ionic deploy - cordova.js not found after update HOT 1
- Ionic Auth - password reset through passwordResetUrl sends two mails HOT 4
- IOS *-Info.Plist. LSApplicationQueriesSchemes. HOT 1
- Setting PHOTOLIBRARY_USAGE_DESCRIPTION parameter with ionic cloud build HOT 2
- deploy.check() never resolved
- Update Docs to match Ionic Pro Dashboard
- Vulnerability due to outdated superagent dependency HOT 1
- Error: Cannot find module 'xml2js'
- Ionic Cloud - android build failed
- No migration guide
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 legacy-ionic-cloud.