Repository navigation
v3.0.0
3.0.0 changes how the architecture artifact's MVI conventions lay out a feature. mvi and navigation are unchanged.
dependencies {
implementation("com.github.kaleidot725.PulseDesktop:mvi:v3.0.0")
implementation("com.github.kaleidot725.PulseDesktop:navigation:v3.0.0")
testImplementation("com.github.kaleidot725.PulseDesktop:architecture:v3.0.0")
}The new layout
counter/
├── CounterHost.kt # host: creates the ViewModels and the Container, lays out the contents
├── CounterContainer.kt
├── CounterContracts.kt # the Container's broadcasts and unicasts
├── content/
│ └── total/
│ ├── TotalContent.kt # binds TotalViewModel with PulseContent
│ ├── TotalViewModel.kt
│ ├── TotalContracts.kt # the ViewModel's state, actions and events
│ ├── section/ # pure composables only this content draws with
│ └── component/
├── section/ # pure: a part of the screen, drawn from a state and callbacks
└── component/ # pure: a small building block
The root of a feature is the package a content package sits in. A composable that returns a value, such as a label read with stringResource, is not a view and may live anywhere.
Checks
| 2.x | 3.0.0 |
|---|---|
assertStatesAndMessagesLiveInTheStatePackage |
assertStatesAndMessagesLiveInContracts — states and messages live in a …Contracts.kt file beside their ViewModel or Container |
assertSectionsBindOneViewModel |
assertContentsBindAViewModel — a content calls PulseContent |
assertComponentsAreStateless |
assertSectionsAndComponentsArePure — sections and components take no ViewModel or Container and bind nothing |
assertScreensComposeSections |
assertHostsComposeContents — a composable at the feature root is in a …Host file and does not call PulseContent |
assertComponentsHavePreviews |
assertSectionsAndComponentsHavePreviews — sections and components have <Name>_Preview |
| — | assertViewModelsLiveInContents — a ViewModel lives under content |
| — | assertContainersLiveAtTheFeatureRoot — a Container lives at the feature root |
| — | assertViewsHaveARole — a composable in a feature is a host, a content, a section or a component |
Queries: pulseFeatureRoots, pulseHosts and pulseContents are added; pulseScreens is removed.
Migrating from 2.x
- Move the states and messages of each ViewModel or Container into a
…Contracts.ktfile in its package, and remove thestatepackages - Name the screen file
…Hostand keep it at the feature root beside the Container - Move each ViewModel and the composable that binds it into
content/<name>; what used to be a section that bound a ViewModel is now a content - Move the stateless overloads that sat beside a binding into a
sectionpackage, with a<Name>_Preview - Replace calls to the renamed assertions and to
pulseScreens
See Architecture checks for the details.