Skip to content

Commit

Permalink
compiler: tag auto-subscribe stores as referenced in vars (#4089)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Kondrad authored and Conduitry committed Dec 11, 2019
1 parent 0a6310f commit 6c0fb5b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/compiler/compile/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ export default class Component {
const subscribable_name = name.slice(1);

const variable = this.var_lookup.get(subscribable_name);
if (variable) variable.subscribable = true;
if (variable) {
variable.referenced = true;
variable.subscribable = true;
}
} else {
this.used_names.add(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function instance($$self, $$props, $$invalidate) {
let $foo;
const foo = writable(0);
component_subscribe($$self, foo, value => $$invalidate(0, $foo = value));
return [$foo];
return [$foo, foo];
}

class Component extends SvelteComponent {
Expand Down
2 changes: 1 addition & 1 deletion test/vars/samples/store-referenced/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
module: false,
mutated: false,
reassigned: false,
referenced: false,
referenced: true,
referenced_from_script: false,
writable: true
},
Expand Down

0 comments on commit 6c0fb5b

Please sign in to comment.