From c41d2e080e7fd75f8c46b724ff4a0f92374ad51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E7=A5=BA?= Date: Wed, 10 May 2017 19:37:02 +0800 Subject: [PATCH 1/2] fix es6 promisify error in RN42+ --- index.js | 10 +++++++++- package.json | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 5d1ca37..2c8d708 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,15 @@ */ import {NativeModules, NativeAppEventEmitter} from 'react-native'; -import promisify from 'es6-promisify'; + +function promisify(fn, handler) { + return function (...args) { + return new Promise(function () { + fn(...args, handler.bind(this)) + }) + } +} + const {WeiboAPI} = NativeModules; diff --git a/package.json b/package.json index 5bc592b..d94cc3d 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,5 @@ "url": "https://github.com/reactnativecn/react-native-weibo/issues" }, "homepage": "https://github.com/reactnativecn/react-native-weibo#readme", - "dependencies": { - "es6-promisify": "^3.0.0" - } + "dependencies": {} } From ef65ce240cab7e71e3791135d3545e8586127009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E7=A5=BA?= Date: Wed, 10 May 2017 19:58:57 +0800 Subject: [PATCH 2/2] fix promise --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 2c8d708..8fbfef8 100644 --- a/index.js +++ b/index.js @@ -6,8 +6,8 @@ import {NativeModules, NativeAppEventEmitter} from 'react-native'; function promisify(fn, handler) { return function (...args) { - return new Promise(function () { - fn(...args, handler.bind(this)) + return new Promise(function (resolve, reject) { + fn(...args, handler.bind({ resolve, reject })) }) } }