From 714343066776131c7bda9fb5f3808af42407db50 Mon Sep 17 00:00:00 2001 From: "ilya.veklenko" Date: Tue, 17 Oct 2017 15:33:18 +0300 Subject: [PATCH 1/2] feat (Promisified): add checking of existing of Promise API --- src/users/social/facebook.js | 4 ++++ src/users/social/google.js | 3 +++ src/utils.js | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/users/social/facebook.js b/src/users/social/facebook.js index c4008815..1477a359 100644 --- a/src/users/social/facebook.js +++ b/src/users/social/facebook.js @@ -1,4 +1,6 @@ + import Async from '../../request/async' +import Utils from '../../utils' import { loginSocial } from './login' import { sendSocialLoginRequest } from './request' @@ -8,6 +10,8 @@ export const loginWithFacebook = (fieldsMapping, permissions, stayLoggedIn, asyn } export const loginWithFacebookSdk = (fieldsMapping, stayLoggedIn, options) => { + Utils.checkPromiseSupport() + return new Promise((resolve, reject) => { if (!FB) { return reject(new Error('Facebook SDK not found')) diff --git a/src/users/social/google.js b/src/users/social/google.js index 78611327..463d3d53 100644 --- a/src/users/social/google.js +++ b/src/users/social/google.js @@ -1,4 +1,5 @@ import Async from '../../request/async' +import Utils from '../../utils' import { loginSocial } from './login' import { sendSocialLoginRequest } from './request' @@ -8,6 +9,8 @@ export const loginWithGooglePlus = (fieldsMapping, permissions, container, stayL } export const loginWithGooglePlusSdk = (fieldsMapping, stayLoggedIn) => { + Utils.checkPromiseSupport() + return new Promise((resolve, reject) => { if (!gapi) { return reject(new Error('Google Plus SDK not found')) diff --git a/src/utils.js b/src/utils.js index f8ded02a..4a8758b9 100644 --- a/src/utils.js +++ b/src/utils.js @@ -150,6 +150,8 @@ const Utils = { promisified(method) { return function() { + Utils.checkPromiseSupport() + const args = [].slice.call(arguments) const context = this const fn = typeof method === 'function' ? method : context[method] @@ -170,6 +172,15 @@ const Utils = { return fn.apply(context, arguments) } + }, + + checkPromiseSupport() { + if (typeof Promise === 'undefined') { + throw new Error( + 'This browser doesn\'t support Promise API. Please use polyfill.\n' + + 'More info is in the Backendless JS-SDK docs: https://backendless.com/docs/js/doc.html#sync-and-async-calls' + ) + } } } From 8e69413c9dbe458fe3b83d29472a8508d2d91046 Mon Sep 17 00:00:00 2001 From: "ilya.veklenko" Date: Tue, 17 Oct 2017 15:35:44 +0300 Subject: [PATCH 2/2] feat (Promisified): add checking of existing of Promise API --- src/users/social/facebook.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/users/social/facebook.js b/src/users/social/facebook.js index 1477a359..9a737d7a 100644 --- a/src/users/social/facebook.js +++ b/src/users/social/facebook.js @@ -1,4 +1,3 @@ - import Async from '../../request/async' import Utils from '../../utils'