A small amount of data is currently stored in plist files. Initial goals were:
- prevent complexity overhead of Core Data
- prevent data loss when we auto-create the database (if a migration fails)
- make data typed
- inject storage layer as dependency.
Retrieving and storing the data is done via AppSettingsAction
and most of the logic happens in AppSettingsStore
.
There are a few data models + plist files separated for specific features and use cases.
GeneralAppSettings
handles settings universal to all stores.GeneralStoreSettings
handles settings unique for each store. Cleared on logout.StoredProductSettings
handles products-specific settings, unique for each store. Cleared on logout.StoredOrderSettings
handles orders-specific settings, unique for each store. Cleared on logout.
Example for store settings use case:
- Add property to data model (
GeneralStoreSettings.swift
). - Run
rake generate
to updateCopiable
implementation. - Add get and set actions in
AppSettingsAction.swift
. - Implement new actions in
AppSettingsStore.swift
. Use existinggetStoreSettings(for:)
andsetStoreSettings(settings:, for:)
helpers +storeSettings.copy(...)
to update non-mutable settings struct.