Skip to content
This repository was archived by the owner on Nov 9, 2023. It is now read-only.

Allows updating more resources automagically #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"version": "0.35.1",
"type": "module",
"license": "MIT",
"exports": {
".": {
"import": "./dist/index.js",
Expand Down
8 changes: 6 additions & 2 deletions src/stores/getValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export const getValue = <T extends JSONValue = JSONValue>(
const adStore = get(store);
let resource: Resource = get(resourceStore);

resourceStore.subscribe(r => (resource = r));

let value: T | undefined = resource.get(property) as T;
const subscriptions = new Set<ValueSubscriber<T>>();
let subscribedToStore = false;
Expand Down Expand Up @@ -85,5 +83,11 @@ export const getValue = <T extends JSONValue = JSONValue>(
},
};

resourceStore.subscribe(r => {
value = r.get(property) as T;
resource = r;
notifySvelteChange();
});

return writable;
};