Improve StateStore documentation and naming.

This commit is contained in:
David Langley
2021-09-15 14:04:18 +01:00
parent da5fcd5d4f
commit e01fd46b2e
4 changed files with 119 additions and 42 deletions
@@ -51,12 +51,12 @@ struct TemplateUserProfile: View {
.toolbar {
ToolbarItem(placement: .primaryAction) {
Button(VectorL10n.done) {
viewModel.inputActions.send(.done)
viewModel.send(viewAction: .done)
}
}
ToolbarItem(placement: .cancellationAction) {
Button(VectorL10n.cancel) {
viewModel.inputActions.send(.cancel)
viewModel.send(viewAction: .cancel)
}
}
}
@@ -37,7 +37,7 @@ class TemplateUserProfileViewModel: TemplateUserProfileViewModelType, TemplateUs
var completion: ((TemplateUserProfileViewModelResult) -> Void)?
// MARK: - Setup
static func makeTemplateUserProfileViewModel(templateUserProfileService: TemplateUserProfileServiceProtocol) -> TemplateUserProfileViewModelProtocol {
return TemplateUserProfileViewModel(templateUserProfileService: templateUserProfileService)
}
@@ -72,14 +72,8 @@ class TemplateUserProfileViewModel: TemplateUserProfileViewModelType, TemplateUs
done()
}
}
/// A redux style reducer
///
/// All modifications to state happen here.
/// - Parameters:
/// - state: The `inout` state to be modified,
/// - action: The action that defines which state modification should take place.
private static func reducer(state: inout TemplateUserProfileViewState, action: TemplateUserProfileStateAction) {
override class func reducer(state: inout TemplateUserProfileViewState, action: TemplateUserProfileStateAction) {
switch action {
case .updatePresence(let presence):
state.presence = presence