5 Matching Annotations
  1. Nov 2021
    1. 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.
    1. 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):
    2. In order to use this, we need to use a little more advanced readable store. Here's your example updated for this:
    3. // 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; }
    4. Here's how we would rewrite our callback example with a store instead: