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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Merge requests
!19
Update example app
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Update example app
feature/example-app-landing
into
development
Overview
0
Commits
9
Pipelines
0
Changes
7
Merged
Update example app
Dariusz Rybicki
requested to merge
feature/example-app-landing
into
development
Aug 3, 2022
Overview
0
Commits
9
Pipelines
0
Changes
7
This MR updates the example app so it uses the new Bindings wrapper.
Present landing page with options to create or load cMix.
Allow removing cMix if stored.
Start/stop network follower.
Show network follower status.
Observe and display network health status.
Edited
Aug 3, 2022
by
Dariusz Rybicki
0
0
Merge request reports
Viewing commit
4959268b
Prev
Next
Show latest version
7 files
+
0
−
821
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
4959268b
Remove unused features
· 4959268b
Dariusz Rybicki
authored
Aug 3, 2022
Example/example-app/Sources/MyContactFeature/MyContactFeature.swift deleted
100644 → 0
+
0
−
138
View file @ a0c6aff1
import
Combine
import
ComposableArchitecture
import
ComposablePresentation
import
ElixxirDAppsSDK
import
ErrorFeature
public
struct
MyContactState
:
Equatable
{
public
init
(
id
:
UUID
,
contact
:
Data
?
=
nil
,
isMakingContact
:
Bool
=
false
,
error
:
ErrorState
?
=
nil
)
{
self
.
id
=
id
self
.
contact
=
contact
self
.
isMakingContact
=
isMakingContact
self
.
error
=
error
}
public
var
id
:
UUID
public
var
contact
:
Data
?
public
var
isMakingContact
:
Bool
public
var
error
:
ErrorState
?
}
public
enum
MyContactAction
:
Equatable
{
case
viewDidLoad
case
observeMyContact
case
didUpdateMyContact
(
Data
?)
case
makeContact
case
didFinishMakingContact
(
NSError
?)
case
didDismissError
case
error
(
ErrorAction
)
}
public
struct
MyContactEnvironment
{
public
init
(
getClient
:
@escaping
()
->
Client
?,
getIdentity
:
@escaping
()
->
Identity
?,
observeContact
:
@escaping
()
->
AnyPublisher
<
Data
?,
Never
>
,
updateContact
:
@escaping
(
Data
?)
->
Void
,
bgScheduler
:
AnySchedulerOf
<
DispatchQueue
>
,
mainScheduler
:
AnySchedulerOf
<
DispatchQueue
>
,
error
:
ErrorEnvironment
)
{
self
.
getClient
=
getClient
self
.
getIdentity
=
getIdentity
self
.
observeContact
=
observeContact
self
.
updateContact
=
updateContact
self
.
bgScheduler
=
bgScheduler
self
.
mainScheduler
=
mainScheduler
self
.
error
=
error
}
public
var
getClient
:
()
->
Client
?
public
var
getIdentity
:
()
->
Identity
?
public
var
observeContact
:
()
->
AnyPublisher
<
Data
?,
Never
>
public
var
updateContact
:
(
Data
?)
->
Void
public
var
bgScheduler
:
AnySchedulerOf
<
DispatchQueue
>
public
var
mainScheduler
:
AnySchedulerOf
<
DispatchQueue
>
public
var
error
:
ErrorEnvironment
}
public
let
myContactReducer
=
Reducer
<
MyContactState
,
MyContactAction
,
MyContactEnvironment
>
{
state
,
action
,
env
in
switch
action
{
case
.
viewDidLoad
:
return
.
merge
([
.
init
(
value
:
.
observeMyContact
),
])
case
.
observeMyContact
:
struct
EffectId
:
Hashable
{
let
id
:
UUID
}
return
env
.
observeContact
()
.
removeDuplicates
()
.
map
(
MyContactAction
.
didUpdateMyContact
)
.
subscribe
(
on
:
env
.
bgScheduler
)
.
receive
(
on
:
env
.
mainScheduler
)
.
eraseToEffect
()
.
cancellable
(
id
:
EffectId
(
id
:
state
.
id
),
cancelInFlight
:
true
)
case
.
didUpdateMyContact
(
let
contact
):
state
.
contact
=
contact
return
.
none
case
.
makeContact
:
state
.
isMakingContact
=
true
return
Effect
.
future
{
fulfill
in
guard
let
identity
=
env
.
getIdentity
()
else
{
fulfill
(
.
success
(
.
didFinishMakingContact
(
NoIdentityError
()
as
NSError
)))
return
}
do
{
env
.
updateContact
(
try
env
.
getClient
()?
.
makeContactFromIdentity
(
identity
:
identity
))
fulfill
(
.
success
(
.
didFinishMakingContact
(
nil
)))
}
catch
{
fulfill
(
.
success
(
.
didFinishMakingContact
(
error
as
NSError
)))
}
}
.
subscribe
(
on
:
env
.
bgScheduler
)
.
receive
(
on
:
env
.
mainScheduler
)
.
eraseToEffect
()
case
.
didFinishMakingContact
(
let
error
):
state
.
isMakingContact
=
false
if
let
error
=
error
{
state
.
error
=
ErrorState
(
error
:
error
)
}
return
.
none
case
.
didDismissError
:
state
.
error
=
nil
return
.
none
case
.
error
(
_
):
return
.
none
}
}
public
struct
NoIdentityError
:
Error
,
LocalizedError
{
public
init
()
{}
}
#if DEBUG
extension
MyContactEnvironment
{
public
static
let
failing
=
MyContactEnvironment
(
getClient
:
{
fatalError
()
},
getIdentity
:
{
fatalError
()
},
observeContact
:
{
fatalError
()
},
updateContact
:
{
_
in
fatalError
()
},
bgScheduler
:
.
failing
,
mainScheduler
:
.
failing
,
error
:
.
failing
)
}
#endif
Loading