Skip to content

Commit

Permalink
Return Promise example
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalumickas committed Sep 23, 2020
1 parent 2b12bc5 commit 289a29d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const appleLogin = require('bindings')('main.node')

const signInWithApple = (mainWindow) => {
const signInWithApple = async (mainWindow) => {
console.log('main window', mainWindow);
appleLogin.signInWithApple(mainWindow);
return await appleLogin.signInWithApple(mainWindow);
}

module.exports = {
Expand Down
15 changes: 10 additions & 5 deletions main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@

AppleLogin *appleLogin = [[AppleLogin alloc] initWithWindow:win];

NSDictionary *result = [appleLogin initiateLoginProcess:^(NSDictionary * _Nonnull result) {
deferred.Resolve(result);
} errorHandler:^(NSError * _Nonnull error) {
deferred.Reject(error);
}];
Napi::Object obj = Napi::Object::New(env);

obj.Set("hello", "world");
deferred.Resolve(obj);

//NSDictionary *result = [appleLogin initiateLoginProcess:^(NSDictionary * _Nonnull result) {
// deferred.Resolve(result);
//} errorHandler:^(NSError * _Nonnull error) {
// //deferred.Reject(error);
//}];

return deferred.Promise();
}
Expand Down

0 comments on commit 289a29d

Please sign in to comment.