-
- Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
Description
Describe the problem
It is a common pattern to put stores into context for reactivity, even the docs recommend it, however there is one mildly annoying thing when you want to use that store within the same component. See the examples below (imports removed for brevity):
This one sparks joy (not possible currently)
<script> const my_store_thing = setContext(key, writable()); </script> Do stuff with {$my_store_thing} in the same component.
This one does not
<script> const my_store_thing = writable(); setContext(key, my_store_thing); // my_store_thing is repeated here. </script> Do stuff with {$my_store_thing} in the same component.
Describe the proposed solution
Make setContext return the value that was passed into it as the second argument. Should be a non breaking change AFAIK unless people are doing weird things with it.
Alternatives considered
Leave things as is.
Importance
would make my life easier
brunnerh and brandonmcconnell