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
92febf27
Commit
92febf27
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add ConnectionPartnerProvider
parent
4cc1c04a
No related branches found
No related tags found
1 merge request
!2
Bindings API wrapper
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/ElixxirDAppsSDK/Connection.swift
+4
-14
4 additions, 14 deletions
Sources/ElixxirDAppsSDK/Connection.swift
Sources/ElixxirDAppsSDK/ConnectionPartnerProvider.swift
+41
-0
41 additions, 0 deletions
Sources/ElixxirDAppsSDK/ConnectionPartnerProvider.swift
with
45 additions
and
14 deletions
Sources/ElixxirDAppsSDK/Connection.swift
+
4
−
14
View file @
92febf27
...
@@ -2,7 +2,7 @@ import Bindings
...
@@ -2,7 +2,7 @@ import Bindings
public
struct
Connection
{
public
struct
Connection
{
public
var
isAuthenticated
:
()
->
Bool
public
var
isAuthenticated
:
()
->
Bool
public
var
getPartner
:
()
->
Data
public
var
getPartner
:
ConnectionPartnerProvider
public
var
send
:
MessageSender
public
var
send
:
MessageSender
public
var
listen
:
MessageListener
public
var
listen
:
MessageListener
public
var
close
:
ConnectionCloser
public
var
close
:
ConnectionCloser
...
@@ -14,12 +14,7 @@ extension Connection {
...
@@ -14,12 +14,7 @@ extension Connection {
)
->
Connection
{
)
->
Connection
{
Connection
(
Connection
(
isAuthenticated
:
{
false
},
isAuthenticated
:
{
false
},
getPartner
:
{
getPartner
:
.
live
(
bindingsConnection
:
bindingsConnection
),
guard
let
data
=
bindingsConnection
.
getPartner
()
else
{
fatalError
(
"BindingsConnection.getPartner returned `nil`"
)
}
return
data
},
send
:
.
live
(
bindingsConnection
:
bindingsConnection
),
send
:
.
live
(
bindingsConnection
:
bindingsConnection
),
listen
:
.
live
(
bindingsConnection
:
bindingsConnection
),
listen
:
.
live
(
bindingsConnection
:
bindingsConnection
),
close
:
.
live
(
bindingsConnection
:
bindingsConnection
)
close
:
.
live
(
bindingsConnection
:
bindingsConnection
)
...
@@ -31,12 +26,7 @@ extension Connection {
...
@@ -31,12 +26,7 @@ extension Connection {
)
->
Connection
{
)
->
Connection
{
Connection
(
Connection
(
isAuthenticated
:
bindingsAuthenticatedConnection
.
isAuthenticated
,
isAuthenticated
:
bindingsAuthenticatedConnection
.
isAuthenticated
,
getPartner
:
{
getPartner
:
.
live
(
bindingsAuthenticatedConnection
:
bindingsAuthenticatedConnection
),
guard
let
data
=
bindingsAuthenticatedConnection
.
getPartner
()
else
{
fatalError
(
"BindingsAuthenticatedConnection.getPartner returned `nil`"
)
}
return
data
},
send
:
.
live
(
bindingsAuthenticatedConnection
:
bindingsAuthenticatedConnection
),
send
:
.
live
(
bindingsAuthenticatedConnection
:
bindingsAuthenticatedConnection
),
listen
:
.
live
(
bindingsAuthenticatedConnection
:
bindingsAuthenticatedConnection
),
listen
:
.
live
(
bindingsAuthenticatedConnection
:
bindingsAuthenticatedConnection
),
close
:
.
live
(
bindingsAuthenticatedConnection
:
bindingsAuthenticatedConnection
)
close
:
.
live
(
bindingsAuthenticatedConnection
:
bindingsAuthenticatedConnection
)
...
@@ -48,7 +38,7 @@ extension Connection {
...
@@ -48,7 +38,7 @@ extension Connection {
extension
Connection
{
extension
Connection
{
public
static
let
failing
=
Connection
(
public
static
let
failing
=
Connection
(
isAuthenticated
:
{
fatalError
(
"Not implemented"
)
},
isAuthenticated
:
{
fatalError
(
"Not implemented"
)
},
getPartner
:
{
fatalError
(
"Not implemented"
)
}
,
getPartner
:
.
failing
,
send
:
.
failing
,
send
:
.
failing
,
listen
:
.
failing
,
listen
:
.
failing
,
close
:
.
failing
close
:
.
failing
...
...
This diff is collapsed.
Click to expand it.
Sources/ElixxirDAppsSDK/ConnectionPartnerProvider.swift
0 → 100644
+
41
−
0
View file @
92febf27
import
Bindings
public
struct
ConnectionPartnerProvider
{
public
var
get
:
()
->
Data
public
func
callAsFunction
()
->
Data
{
get
()
}
}
extension
ConnectionPartnerProvider
{
public
static
func
live
(
bindingsConnection
:
BindingsConnection
)
->
ConnectionPartnerProvider
{
ConnectionPartnerProvider
{
guard
let
data
=
bindingsConnection
.
getPartner
()
else
{
fatalError
(
"BindingsConnection.getPartner returned `nil`"
)
}
return
data
}
}
public
static
func
live
(
bindingsAuthenticatedConnection
:
BindingsAuthenticatedConnection
)
->
ConnectionPartnerProvider
{
ConnectionPartnerProvider
{
guard
let
data
=
bindingsAuthenticatedConnection
.
getPartner
()
else
{
fatalError
(
"BindingsAuthenticatedConnection.getPartner returned `nil`"
)
}
return
data
}
}
}
#if DEBUG
extension
ConnectionPartnerProvider
{
public
static
let
failing
=
ConnectionPartnerProvider
{
fatalError
(
"Not implemented"
)
}
}
#endif
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