5 Matching Annotations
- Nov 2021
-
-
Abstract the whole queryCommandState / execCommand system into a store (or some wrapper that also holds a store) that has state like isBold and canMakeBold and a makeBold() function.
-
-
stackoverflow.com stackoverflow.com
-
The consumer component will barely change from our last example. The only difference is the way we'll get a reference to our store (since now the store is exported from the JS module):
-
In order to use this, we need to use a little more advanced readable store. Here's your example updated for this:
-
// our temperature is now a store with initial value 0 const temperature = writable(0); // now we don't need to change this function, the change will be propaged // by the store itself const getTemperature = () => { return temperature; }
-
Here's how we would rewrite our callback example with a store instead:
-