Skip to content

Document that state fields only see assignments, not in-place edits - #32

Merged
wf9a5m75 merged 1 commit into
developfrom
docs/state-assign-new-list
Nov 9, 2026
Merged

wf9a5m75 merged 1 commit into
developfrom
docs/state-assign-new-list

Conversation

@wf9a5m75

@wf9a5m75 wf9a5m75 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

なぜ

07e614f 以降、ComponentState は自分のプロパティへの代入でだけ変更を通知する。リストをその場で書き換えても、内容の等しいリストを代入し直しても通知されない。example の Polygon / Polyline ページがこの書き方で頂点ドラッグに追従しなくなっていた(MapConductor/android-sdk#116 で example 側を直した)。この性質が KDoc に書かれていなかった。

何を変えたか(KDoc のみ。振る舞い・公開 API は変えていない)

  • PolygonState.points / holes、PolylineState.points: 見ているのは代入だけ。mutableStateListOf を渡してその場で書き換えても描き直されない。新しいリストを代入する(例つき)。内容の等しいリストの代入は無視される。
  • RasterLayerState.extraHeaders: Map も同じ。
  • ComponentState.mutations、StateMutationSignal.notifying: 一般則として同じことを一文。
  • Circle・GroundImage・Marker の通知されるフィールドには List / Map / 配列が無いので触っていない。

検証

  • assembleRelease、apiCheck(変化なし)、OverlayCollectorMutationTest 5 件 pass。
  • ktlint は develop の時点で失敗している(違反数は変更前後で同じ 67 行、今回の追加分は無し)。

関連: MapConductor/website-2nd の docs/state-assign-new-list(サンプルのコメント)。

PolygonState.points/holes, PolylineState.points and RasterLayerState.extraHeaders
are watched only through assignment. A list passed in and then edited in place
(mutableStateListOf, MutableList) is never redrawn, and re-assigning the same
edited list is dropped as equal. Say so on the fields and on
ComponentState.mutations / StateMutationSignal.notifying. KDoc only.
@wf9a5m75
wf9a5m75 merged commit c87c175 into develop Nov 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant