Skip to content

Commit 3afa5e5

Browse files
committed
Add loading listener to @tomic/svelte getResource
1 parent b4a16f4 commit 3afa5e5

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"javascript",
1414
"javascriptreact",
1515
"typescript",
16-
"typescriptreact"
16+
"typescriptreact",
17+
"svelte",
18+
"svlete.ts"
1719
],
1820
"typescript.preferences.importModuleSpecifierEnding": "minimal",
1921
"eslint.alwaysShowStatus": true,

browser/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ This changelog covers all five packages, as they are (for now) updated as a whol
2929
- Fix types masquerading as esm module in cjs build.
3030
- `store.search()` now handles multiple values for the same property correctly.
3131
- [#1077](https://github.com/atomicdata-dev/atomic-server/issues/1077) Fix bug where resource.new would not be set back to true when saving fails.
32+
- Added `ResourceEvents.LoadingChange` event on `Resource` to listen for changes to the loading state of the resource.
33+
- Added `resource.stable` property to `Resource` to get a stable reference to the resource, even when it is proxied.
34+
- Added `resource.merge()` method to merge a resource into another resource while preserving local changes on the current resource.
35+
- `store.addResources()` now merges incoming resources with resources already present in the store.
3236
- SEMI BREAKING CHANGE: When using generated types by cli, @tomic/lib now requires them to be generated by @tomic/cli v0.41.0 or above.
3337
- BREAKING CHANGE: The `StoreEvents.ResourceRemoved` event callback now only receives the subject of the resource instead of the resource itself.
3438

browser/svelte/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default [
2020
},
2121
},
2222
{
23-
files: ['**/*.svelte'],
23+
files: ['**/*.svelte', '**/*.svlete.ts'],
2424
languageOptions: {
2525
parserOptions: {
2626
parser: ts.parser,

browser/svelte/src/lib/stores/getResource.svelte.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,18 @@ export function getResource<T extends OptionalClass = never>(
6666
resource = proxyResource(resource.__internalObject);
6767
});
6868

69+
const unsubLoading = resource.on(ResourceEvents.LoadingChange, () => {
70+
resource = proxyResource(resource.__internalObject);
71+
});
72+
6973
const unsubRemote = store.subscribe(subject, r => {
7074
resource = proxyResource(r);
7175
});
7276

7377
return () => {
7478
unsubLocal();
7579
unsubRemote();
80+
unsubLoading();
7681
};
7782
});
7883

0 commit comments

Comments
 (0)