feat: let promise reject called

This commit is contained in:
pengfei.zhou 2021-06-22 16:36:34 +08:00 committed by osborn
parent 901d3fdf72
commit 3f6d88bbe7
7 changed files with 7 additions and 7 deletions

View File

@ -1298,12 +1298,12 @@ var doric = (function (exports) {
Context.prototype.callNative = function (namespace, method, args) { Context.prototype.callNative = function (namespace, method, args) {
var _this = this; var _this = this;
var callbackId = uniqueId('callback'); var callbackId = uniqueId('callback');
nativeBridge(this.id, namespace, method, callbackId, args);
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
_this.callbacks.set(callbackId, { _this.callbacks.set(callbackId, {
resolve: resolve, resolve: resolve,
reject: reject, reject: reject,
}); });
nativeBridge(_this.id, namespace, method, callbackId, args);
}); });
}; };
Context.prototype.register = function (instance) { Context.prototype.register = function (instance) {

View File

@ -1300,12 +1300,12 @@ var doric = (function (exports) {
} }
callNative(namespace, method, args) { callNative(namespace, method, args) {
const callbackId = uniqueId('callback'); const callbackId = uniqueId('callback');
nativeBridge(this.id, namespace, method, callbackId, args);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.callbacks.set(callbackId, { this.callbacks.set(callbackId, {
resolve, resolve,
reject, reject,
}); });
nativeBridge(this.id, namespace, method, callbackId, args);
}); });
} }
register(instance) { register(instance) {

View File

@ -1329,12 +1329,12 @@ class Context {
} }
callNative(namespace, method, args) { callNative(namespace, method, args) {
const callbackId = uniqueId('callback'); const callbackId = uniqueId('callback');
nativeBridge(this.id, namespace, method, callbackId, args);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.callbacks.set(callbackId, { this.callbacks.set(callbackId, {
resolve, resolve,
reject, reject,
}); });
nativeBridge(this.id, namespace, method, callbackId, args);
}); });
} }
register(instance) { register(instance) {

View File

@ -118,12 +118,12 @@ export class Context {
} }
callNative(namespace, method, args) { callNative(namespace, method, args) {
const callbackId = uniqueId('callback'); const callbackId = uniqueId('callback');
nativeBridge(this.id, namespace, method, callbackId, args);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.callbacks.set(callbackId, { this.callbacks.set(callbackId, {
resolve, resolve,
reject, reject,
}); });
nativeBridge(this.id, namespace, method, callbackId, args);
}); });
} }
register(instance) { register(instance) {

View File

@ -136,12 +136,12 @@ export class Context {
} }
callNative(namespace: string, method: string, args?: any): Promise<any> { callNative(namespace: string, method: string, args?: any): Promise<any> {
const callbackId = uniqueId('callback') const callbackId = uniqueId('callback')
nativeBridge(this.id, namespace, method, callbackId, args)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.callbacks.set(callbackId, { this.callbacks.set(callbackId, {
resolve, resolve,
reject, reject,
}) })
nativeBridge(this.id, namespace, method, callbackId, args)
}) })
} }
register(instance: Object) { register(instance: Object) {

View File

@ -174,12 +174,12 @@ export class Context {
} }
callNative(namespace: string, method: string, args?: any): Promise<any> { callNative(namespace: string, method: string, args?: any): Promise<any> {
const callbackId = uniqueId('callback') const callbackId = uniqueId('callback')
nativeBridge(this.id, namespace, method, callbackId, args)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.callbacks.set(callbackId, { this.callbacks.set(callbackId, {
resolve, resolve,
reject, reject,
}) })
nativeBridge(this.id, namespace, method, callbackId, args)
}) })
} }
register(instance: Object) { register(instance: Object) {

View File

@ -1302,12 +1302,12 @@ var doric = (function (exports) {
} }
callNative(namespace, method, args) { callNative(namespace, method, args) {
const callbackId = uniqueId('callback'); const callbackId = uniqueId('callback');
nativeBridge(this.id, namespace, method, callbackId, args);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.callbacks.set(callbackId, { this.callbacks.set(callbackId, {
resolve, resolve,
reject, reject,
}); });
nativeBridge(this.id, namespace, method, callbackId, args);
}); });
} }
register(instance) { register(instance) {