Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Commits
9383977d
Commit
9383977d
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add UdMultiLookupCallback
parent
8756a012
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!102
Release 1.0.0
,
!90
Update Bindings
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Sources/XXClient/Callbacks/UdMultiLookupCallback.swift
+55
-0
55 additions, 0 deletions
Sources/XXClient/Callbacks/UdMultiLookupCallback.swift
with
55 additions
and
0 deletions
Sources/XXClient/Callbacks/UdMultiLookupCallback.swift
0 → 100644
+
55
−
0
View file @
9383977d
import
Bindings
import
XCTestDynamicOverlay
public
struct
UdMultiLookupCallback
{
public
enum
Result
:
Equatable
{
case
success
([
Contact
])
case
failure
(
error
:
NSError
,
failedIDs
:
[
Data
])
}
public
init
(
handle
:
@escaping
(
Result
)
->
Void
)
{
self
.
handle
=
handle
}
public
var
handle
:
(
Result
)
->
Void
}
extension
UdMultiLookupCallback
{
public
static
let
unimplemented
=
UdMultiLookupCallback
(
handle
:
XCTUnimplemented
(
"
\(
Self
.
self
)
"
)
)
}
extension
UdMultiLookupCallback
{
func
makeBindingsUdMultiLookupCallback
()
->
BindingsUdMultiLookupCallbackProtocol
{
class
CallbackObject
:
NSObject
,
BindingsUdMultiLookupCallbackProtocol
{
init
(
_
callback
:
UdMultiLookupCallback
)
{
self
.
callback
=
callback
}
let
callback
:
UdMultiLookupCallback
func
callback
(
_
contactListJSON
:
Data
?,
failedIDs
:
Data
?,
err
:
Error
?)
{
if
let
err
=
err
{
callback
.
handle
(
.
failure
(
error
:
err
as
NSError
,
failedIDs
:
failedIDs
.
map
{
(
try
?
JSONDecoder
()
.
decode
([
Data
]
.
self
,
from
:
$0
))
??
[]
}
??
[]
))
}
else
if
let
contactListJSON
=
contactListJSON
{
do
{
let
contactsData
=
try
JSONDecoder
()
.
decode
([
Data
]
.
self
,
from
:
contactListJSON
)
let
contacts
:
[
Contact
]
=
contactsData
.
map
{
Contact
.
live
(
$0
)
}
callback
.
handle
(
.
success
(
contacts
))
}
catch
{
callback
.
handle
(
.
failure
(
error
:
error
as
NSError
,
failedIDs
:
[]))
}
}
else
{
fatalError
(
"BindingsUdMultiLookupCallbackProtocol received `nil` contactListJSON and `nil` error"
)
}
}
}
return
CallbackObject
(
self
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment