You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using MutableObservableArray quite a bit to populate some UITableViews which use the AccessoryType.checkmark to indicate whether a particular cell has been selected or not.
An example of this is MutableObservableArray<RecurrenceByDayOfWeek> which leverages :
// Model defines
public struct RecurrenceByDayOfWeek {
public let weekday: ShortWeekDays
public let ordwk: Int
public let selected: Bool
}
// Service defines
public let byDay: MutableObservableArray<RecurrenceByDayOfWeek> =
MutableObservableArray(
ShortWeekDays.allCases.map {
RecurrenceByDayOfWeek(weekday: $0,selected: false)
}
)
// Binder defines
recurrenceService.byDay.compactMap { $0.collection }
.observeNext { recurrence in
recurrence.indices.forEach { index in
let cell = controller
.recurrenceTableView
.cellForRow(at: IndexPath(row: index, section: 1))
cell?.accessoryType = recurrence[index].selected ? .checkmark : .none
}
}.dispose(in: controller.bag)
to indicate whether a day of the week has been selected or not in a table presenting ShortWeekDays (MO, TU, WE, etc.). This helps the end user create a recurrence rule akin to the following examples :
While this works fine, the Application logic clearly encroaches on the Business logic / Model. The data itself should only care about which days to include in the BYDAY part of the recurrence rule (if any).
So being "selected" is only a mapping convenience between that state and the resulting string.
Question
So what would be the best way to decouple the Application logic from the Model ? Or is the Model itself (for this case) just a String anyways ?
Should everything we're building to organize the structure of the BYDAY rule part (and by extension, the complete RRULE string) just be some extension of the Application logic (to make it more palatable to structure that data) ?
I am a little confused for this particular scenario.
The text was updated successfully, but these errors were encountered:
Context
I am using MutableObservableArray quite a bit to populate some
UITableView
s which use theAccessoryType.checkmark
to indicate whether a particular cell has been selected or not.An example of this is
MutableObservableArray<RecurrenceByDayOfWeek>
which leverages :to indicate whether a day of the week has been selected or not in a table presenting
ShortWeekDays
(MO, TU, WE, etc.). This helps the end user create a recurrence rule akin to the following examples :Distinction between Model, Service and Binding
While this works fine, the Application logic clearly encroaches on the Business logic / Model. The data itself should only care about which days to include in the BYDAY part of the recurrence rule (if any).
So being "selected" is only a mapping convenience between that state and the resulting string.
Question
So what would be the best way to decouple the Application logic from the Model ? Or is the Model itself (for this case) just a String anyways ?
Should everything we're building to organize the structure of the BYDAY rule part (and by extension, the complete RRULE string) just be some extension of the Application logic (to make it more palatable to structure that data) ?
I am a little confused for this particular scenario.
The text was updated successfully, but these errors were encountered: