This commit is contained in:
Tomas Dvorak
2026-02-24 10:33:59 +01:00
parent 409acd2e08
commit 898a3c303f
1374 changed files with 290409 additions and 29187 deletions
+17
View File
@@ -0,0 +1,17 @@
{
"id": "c200dfe99d2c9f1680cd1e4d",
"source": "solid:signals",
"type": "github-document",
"title": "reconcile",
"content": "---\ntitle: reconcile\nuse_cases: \u003e-\n api responses, data synchronization, immutable data diffing, observable\n subscriptions, large data updates\ntags:\n - store\n - diffing\n - api\n - synchronization\n - immutable\nversion: '1.0'\ndescription: \u003e-\n Efficiently diff and merge data changes with reconcile. Perfect for syncing\n API responses or handling immutable data updates.\n---\n\n`reconcile` is designed for diffing data changes in situations where granular updates cannot be applied.\nThis is useful when dealing with immutable data from stores or handling large API responses.\n\n```tsx\nimport { reconcile } from \"solid-js/store\"\nimport type { NotWrappable, Store } from \"solid-js/store\"\n\nfunction reconcile\u003cT\u003e(\n\tvalue: T | Store\u003cT\u003e,\n\toptions?: {\n\t\tkey?: string | null;\n\t\tmerge?: boolean;\n\t} = { key: \"id\" }\n): (\n\tstate: T extends NotWrappable ? T : Store\u003cT\u003e\n) =\u003e T extends NotWrappable ? T : Store\u003cT\u003e\n```\n\n`reconcile` has a `key` option that can be used when available to match items.\nThe `value` accepts either a value of type `T` or a Store containing values of type `T`.\nThis represents the data to be reconciled.\n\nThe `reconcile` function helps manage data changes by performing a diffing process, making it particularly handy in scenarios where applying granular updates is challenging or inefficient.\n\nThe `key` and `merge` options provide flexibility to customize the reconciliation process based on specific needs.\n\n```ts\n// subscribing to an observable\nconst unsubscribe = store.subscribe(({ todos }) =\u003e (\n setState('todos', reconcile(todos));\n);\nonCleanup(() =\u003e unsubscribe());\n\n```\n\n##### Options\n\n| Option | Type | Default | Description |\n| ------ | ------- | ------- | ---------------------------------- |\n| key | string | \"id\" | Specifies the key to be used for matching items during reconciliation |\n| merge | boolean | false | When merge is false, referential checks are performed where possible to determine equality, and items that are not referentially equal are replaced. When merge is true, all diffing is pushed to the leaves, effectively morphing the previous data to the new value. |",
"url": "https://github.com/solidjs/solid-docs/blob/HEAD/src/routes/reference/store-utilities/reconcile.mdx",
"metadata": {
"path": "src/routes/reference/store-utilities/reconcile.mdx",
"repo": "solidjs/solid-docs",
"repo_url": "https://github.com/solidjs/solid-docs.git",
"size": 2150,
"source_type": "github"
},
"hash": "0347a5464697bccf1a5f06891801537527ede1827ce32f0fce5a0f8ea5259078",
"timestamp": "2026-02-23T11:43:00.190922797+01:00"
}