Repository navigation
行変更の確定結果を操作単位で通知できるようにする - #11
Merged
Merged
Conversation
4 tasks done
kanchi-Matsumoto
force-pushed
the
feat/row-change-commit-notification
branch
from
August 3, 2026 13:09
9e0905d to
0f3cd63
Compare
kanchi-Matsumoto
marked this pull request as ready for review
August 3, 2026 13:50
kanchi-Matsumoto
added a commit
that referenced
this pull request
Aug 5, 2026
RyoSogawa
reviewed
Aug 7, 2026
操作単位の変更前後の行と拒否コンテキストを公開し、利用側での行データの二重管理を不要にする。既存のonChangeは変更しない。
kanchi-Matsumoto
force-pushed
the
feat/row-change-commit-notification
branch
from
August 8, 2026 02:44
d72af06 to
5862caa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
このPRでできること
テーブルで確定した1回の編集について、変更前と変更後の行を利用側で受け取れるようになります。
背景
編集した内容をAPIへ保存するとき、変わった項目だけを送りたいという要求があります。全部送ると無駄が多く、意図しない上書きも起こりえます。
ところが既存の
onChangeは、「保存基準から見て現在変更されている行の一覧」を累積で通知するものでした。これは最後にまとめて保存する用途には向いていますが、「今回の操作でどの状態からどの状態へ変わったか」は分かりません。具体例
診療時間を 20分から30分へ変更したとします。
APIへ送りたいのは「診療時間が30分になりました」という情報だけです。しかし通知されるのは「この行はいま、担当者が田中、開始が09:00、診療時間が30分、…」という現在の姿の一式でした。
これだけでは、診療時間が変わったのか、担当者が変わったのか判断できません。
フロントでやる場合の回避方法とその問題
利用側がテーブルと同じ行データをもう一部保持して、「さきほどは20分だったのに今は30分なので、変わったのは診療時間だ」と突き合わせる必要がありました。
同じ情報を2か所で管理することになるため、片方だけが更新されると画面の表示とAPI更新の内容がずれるおそれがあります。
テーブルはすでに変更前後の行を持っています。それを通知すれば、利用側で二重管理をしなくて済みます。
変更内容
onRowChangeCommittedを追加しましたonRowChangeRejectedへ、変更前の行と変更候補の行を追加しましたonChangeの型と呼び出し方は変更していません利用側は渡された変更前後の行を比べるだけで済むため、自前で行データを保持する必要がなくなります。
PR #8との違い
PR #8 は、行を確定する前に
processRowChangeで補正または拒否できるようにするものです。このPRは、PR #8 で採用された最終的な行を確定した後に、操作直前の行と一緒に利用側へ通知するものです。
補足
onChangeだけを利用しているコードは変更不要です確認
pnpm testpnpm typecheckpnpm lintpnpm build