mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-02-12 06:55:27 +00:00
Try to refactor towards async await & results
This commit is contained in:
parent
da6a82f9ad
commit
26c7cd4122
4 changed files with 19 additions and 13 deletions
|
@ -288,7 +288,7 @@
|
|||
attributes = {
|
||||
BuildIndependentTargetsInParallel = YES;
|
||||
LastSwiftUpdateCheck = 1140;
|
||||
LastUpgradeCheck = 1510;
|
||||
LastUpgradeCheck = 1620;
|
||||
ORGANIZATIONNAME = "The Chromium Authors";
|
||||
TargetAttributes = {
|
||||
43AA89532444DA6500EDC39C = {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1510"
|
||||
LastUpgradeVersion = "1620"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -146,16 +146,19 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
|
|||
}
|
||||
|
||||
func listSites(result: @escaping FlutterResult) {
|
||||
self.sites?.loadSites { (sites, err) -> () in
|
||||
if (err != nil) {
|
||||
return result(CallFailedError(message: "Failed to load site list", details: err!.localizedDescription))
|
||||
}
|
||||
Task {
|
||||
self.sites?.loadSites { (sites, err) -> () in
|
||||
if (err != nil) {
|
||||
return result(CallFailedError(message: "Failed to load site list", details: err!.localizedDescription))
|
||||
}
|
||||
|
||||
let encoder = JSONEncoder()
|
||||
let data = try! encoder.encode(sites)
|
||||
let ret = String(data: data, encoding: .utf8)
|
||||
result(ret)
|
||||
let encoder = JSONEncoder()
|
||||
let data = try! encoder.encode(sites)
|
||||
let ret = String(data: data, encoding: .utf8)
|
||||
result(ret)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func deleteSite(call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
|
|
|
@ -19,10 +19,11 @@ class Sites {
|
|||
self.messenger = messenger
|
||||
}
|
||||
|
||||
func loadSites(completion: @escaping ([String: Site]?, (any Error)?) -> ()) {
|
||||
func loadSites() async -> Result<[String: Site], (any Error)> {
|
||||
var result: Result<[String: Site], (any Error)>?;
|
||||
_ = SiteList { (sites, err) in
|
||||
if (err != nil) {
|
||||
return completion(nil, err)
|
||||
result = Result.failure(err!)
|
||||
}
|
||||
|
||||
sites?.values.forEach{ site in
|
||||
|
@ -38,8 +39,10 @@ class Sites {
|
|||
let justSites = self.containers.mapValues {
|
||||
return $0.site
|
||||
}
|
||||
completion(justSites, nil)
|
||||
result = Result.success(justSites)
|
||||
}
|
||||
|
||||
return result!;
|
||||
}
|
||||
|
||||
func deleteSite(id: String, callback: @escaping ((any Error)?) -> ()) {
|
||||
|
|
Loading…
Reference in a new issue