reconcile: support "merge" in objects
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 38/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- frontend
調査の方向性
まず reconcile と applyState の実装を読み、次に setState がオブジェクトの更新をどのように適用するかを追跡します。既存の配列マージの動作を、提案されている第1レベルのオブジェクトマージと比較し、ネストされた場合に期待される動作について issue の例を確認します。説明されている store 更新パターンをカバーし、現在の配列の動作を維持する部分的なオブジェクト更新用の API が確定すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
A common pattern I believe is to reconcile partial state updates in stores.
For example, part of a store is synced to a backend, so after a push-to-backend operation, it returns an up-to-date data for part of the store values. Other values, like UI related ones are not included in this data.
Passing this raw data into setStore works, but triggers unnecessary updates. It triggers every single key's update, which is an array or object.
Here is my 1st idea to tackle this: running reconcile in a for loop on each 1st level key:
for (const key of Object.keys(data)) {
this.setState(key as any, reconcile(data[key as keyof typeof data]))
}
This works, and when put in a batch() should be performant. Quite a lot of code, so asks for a wrapper function, but should be good.
My 2nd idea is this:
this.setState(reconcile({ ...this.state, ...data }))
This also works. If I understand correctly, it's a tiny bit slower, but the slowness happens in the pure JS code, not in the actual UI updates, so it should still be fast.
When I looked at the source code for reconcile and found that it supports merge, but only for arrays.
I'd like to recommend to add support for merge in objects. To make sure that this does not modify the array behaviours in sub-keys, it should be called something different, "partial" probably.
I believe it'd be as simple as turning off the delete loop in the first level of applyState.
Please tell me if I'm not correct in this. Isn't this a common pattern when using stores?
How do you normally solve this?
- 主要言語
- TypeScript
- スター
- 36.2k
- フォーク
- 1.1k
- 平均マージ
- 11時間 5分
- マージ済み PR(30日)
- 475
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
solidjs/solid のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 28/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 12/100
メンテナーはふだん 1 日以内に返信
-
[2.0 / next] <Errored> recovery shows a pending memo's answer to an older input beside the new inputオープン
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
🎙️ task - drop the raw `./node_modules/.bin/rhachet roles boot` line from bhuild's feedback templateオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ehmpathy/rhachet-roles-bhuild#639 ·
メンテナーはふだん 1 日以内に返信
-
e2e-failure ready-to-code
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
redhat-developer/rhdh-plugin-export-overlays#4650 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 13 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
omdsh-dev/DSH-better-sidebar#1098 ·
メンテナーはふだん 2 日以内に返信