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

Commit

Permalink
Allows updating more resources automagically
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Mar 20, 2023
1 parent d1b12ca commit fefe5b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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;
};

0 comments on commit fefe5b8

Please sign in to comment.