Skip to content

0.8.0

Compare
Choose a tag to compare
@aralroca aralroca released this 14 Nov 10:26
· 37 commits to master since this release
1e98db5

What's changed

Breaking changes

  • One this breaking change for this version: Remove confusing reset feature #44

    Reset function is removed. It's not responsibility of the library. In this way:

    Pros:

    • Removing confusion as to what exactly the reset function did. Simplifying and making it easier to understand.
    • Fewer things in memory. Thus it is not necessary to save the store + initialStore. Only the store. This improves performance for applications with very large stores.
    • Tiniest. Supporting reset made it take up more bits.
    • Removing a feature that did not add value to the library, since the same could be done with the setter.
    • More flexibility to the user to reset with the setter where the user wants: last value, last value fetched to an API, initial value...

    Cons:

    • The user will be responsible for controlling the reset. That is, save the value in memory.

      Example:

      const [value, setValue] = useStore.value()
      const lastValue = useRef(value)
      
      // After some changes, is possible to reset with:
      setValue(lastValue.current)

      Another example:

       const initialStore = { count: 0 }
       export const { getStore } = createStore(initialStore)
       const [,setStore] = getStore()
      
       export const reset = () => setStore(initialStore)
       import { reset } from './store'
      
       function ResetStore() {
         return <button onClick={reset}>Reset store</button>
      }

Full Changelog: 0.7.2...0.8.0