Skip to content

API 概要 ​

PulsePlatform は役割ごとに 1 つのパッケージを公開しています。ルールは jp.kaleidot725.pulse.architecture(architecture アーティファクト)にあります。ライブラリは jp.kaleidot725.pulse.mvi にあり、デスクトップ向けに mvi-desktop、Android と iOS 向けに mvi-mobile として公開しています。Navigation 3 対応は jp.kaleidot725.pulse.navigation にあり、navigation-desktop と navigation-mobile として公開しています。

ルール ​

テストから呼ぶアサートと、その土台のクエリです。ルール API の内容は、検査がどちらかを明記している場合を除き、デスクトップとモバイルのコードの両方に当てはまります。

アサート説明
assertPulseMviConventions続く 12 の検査を順に実行する
assertStatesAreDataTypesPulseState は data class または data object
assertMessagesAreSealedOrDataTypesメッセージは data class / data object のケースを持つ sealed class、または単独の data class / data object
assertStatesAndMessagesLiveInContractsState とメッセージは ViewModel か Container の隣の …Contracts.kt に置く
assertViewModelsAndContainersAreNamedAfterTheirBase…ViewModel と …Container
assertViewModelsHoldTheirDataInTheirStateViewModel と Container は var プロパティを持たない
assertViewModelsLiveInContentsViewModel は content の下に置く
assertContainersLiveAtTheFeatureRootContainer は feature のルートに置く
assertHostsComposeContentsHost は …Host という名前で、ViewModel を束ねず Content を並べる
assertFeaturePackagesHaveARolefeature の中のファイルは、ルートか content・section・component の下にある
assertContentsBindAViewModelContent は PulseContent で ViewModel を束ねる
assertSectionsAndComponentsArePureSection と Component はデータとコールバックだけを受け取る
assertSectionsAndComponentsHavePreviewsすべての Section と Component に <Name>_Preview がある
assertPulseMobileConventionsmvi-mobile のアプリ向けの検査を順に実行する
assertMobileFeaturesHaveOneViewModelモバイルの ViewModel は feature のルートに 1 つだけ置く
assertScreensBindTheirViewModelモバイルの feature のルートの Composable は ViewModel を結びつける …Screen
assertMobileFeaturePackagesHaveARoleモバイルの feature の中のファイルは、ルートか section・component の下にある
assertPulseDomainConventionsRepository は Flow を公開し、ワンショットの取得は Result<V, E> で返す。UseCase は usecase に置き、1 行にしない
assertPulseModuleConventionsモジュール間の依存が Clean Architecture の向きに従い、domain・data・designsystem がパッケージで分かれている
assertPulseKoinConventionsKoin モジュールは app モジュールで定義する
assertPulseResourceConventionsdomain は文言を持たず、Composable は文言を文字列リソースから読む
PulseModuleLayoutどのモジュール名がどの層に当たるか

ライブラリ ​

PulseViewModel、PulseContent、次の 3 つのマーカーは mvi-desktop と mvi-mobile の両方にあります。モバイルの PulseViewModel は型パラメータを 5 つではなく 3 つ取ります。

宣言説明
PulseViewModel1 つの UI 状態を持ち、Action を処理して Event を発行する抽象基底クラス
PulseContentViewModel を観測し、状態と Action のディスパッチャを渡す
PulseStateクラスを ViewModel の UI 状態として印付ける
PulseActionクラスをユーザーの操作として印付ける
PulseEventクラスを一度きりの副作用として印付ける

デスクトップ ​

mvi-desktop だけにあるものです。

宣言説明
PulseContainerウィンドウの ViewModel 群を調整する
PulseHostContainer をサブツリーにスコープし、Refresh と Broadcast のコールバックを渡す
PulseBroadcastクラスを Container の Broadcast メッセージとして印付ける
PulseUnicastクラスを子から親への Unicast メッセージとして印付ける

拡張 ​

Navigation 3 対応は任意で、どのプラットフォームでも同じように使えます。デスクトップ向けは navigation-desktop、Android と iOS 向けは navigation-mobile です。モバイルには Container がないので、rememberPulseContainer は navigation-desktop だけにあります。

宣言説明
rememberPulseViewModelViewModelStoreOwner にスコープされた ViewModel
rememberPulseNavEntryDecoratorsViewModel をバックスタックエントリにスコープする NavDisplay のデコレータ
rememberPulseContainerViewModelStoreOwner にスコープされた Container(デスクトップのみ)

Apache 2.0 License の下で公開されています。