-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Application class with async logIn method (includes stubs for U…
…ser)
- Loading branch information
Showing
9 changed files
with
247 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../src/realm_dart_app.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2022 Realm Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
import 'application_configuration.dart'; | ||
|
||
import 'native/realm_core.dart'; | ||
import 'credentials.dart'; | ||
import 'user.dart'; | ||
|
||
class Application { | ||
final RealmAppHandle _handle; | ||
final ApplicationConfiguration configuration; | ||
|
||
Application(this.configuration) : _handle = realmCore.getApp(configuration); | ||
|
||
Future<User> logIn(Credentials credentials) async { | ||
return UserInternal.create(await realmCore.logIn(this, credentials)); | ||
} | ||
} | ||
|
||
extension ApplicationInternal on Application { | ||
RealmAppHandle get handle => _handle; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,4 @@ class ApplicationConfiguration { | |
this.localAppName, | ||
this.localAppVersion, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2022 Realm Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
import 'native/realm_core.dart'; | ||
|
||
class User { | ||
final RealmUserHandle _handle; | ||
|
||
User._(this._handle); | ||
} | ||
|
||
extension UserInternal on User { | ||
static User create(RealmUserHandle handle) => User._(handle); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2022 Realm Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef REALM_DART_APP_H | ||
#define REALM_DART_APP_H | ||
|
||
#include "realm.h" | ||
#include "dart_api_dl.h" | ||
|
||
/** | ||
* Completion callback for asynchronous Realm App operations that yield a user object. | ||
* | ||
* @param userdata The userdata the asynchronous operation was started with. | ||
* @param user User object produced by the operation, or null if it failed. | ||
* The pointer is alive only for the duration of the callback, | ||
* if you wish to use it further make a copy with realm_clone(). | ||
* @param error Pointer to an error object if the operation failed, otherwise null if it completed successfully. | ||
* | ||
* This is a dart specific version of the completion callback for asynchronous Realm operations. | ||
*/ | ||
typedef void (*realm_dart_app_user_completion_func_t)(Dart_Handle userdata, realm_user_t* user, const realm_app_error_t* error); | ||
|
||
/** | ||
* @brief | ||
* | ||
* @param completion | ||
* @param userdata | ||
* @return true if operation started successfully, false if an error occurred. | ||
*/ | ||
RLM_API bool realm_dart_app_log_in_with_credentials(realm_app_t*, realm_app_credentials_t*, | ||
realm_dart_app_user_completion_func_t completion, Dart_Handle userdata); | ||
|
||
#endif |