Skip to content

0.6.0

Compare
Choose a tag to compare
@aralroca aralroca released this 01 Nov 19:03
· 63 commits to master since this release
9146fdc

0.6 release 🚀

We are taking advantage of the fact that we are in an early stage (0.x) to evolve quickly the library trying to make everything more and more tiny, easy and powerful.

Sorry for the breaking changes and if you have any questions you can write inside GitHub Discussions.

The library is becoming more and more stable and we will make less breaking changes, and from version 1.0 onwards we will follow the semantic version 100%.

🚨 I have to announce that after having changed the name of the library from fragmented-store to fragstore, we are forced to change it again to avoid problems with a company called fragstore that we didn't know about.

We have not changed the name for this version as it already has some breaking changes. But we will change it for the next version and it will be the only breaking change for the future 0.7 version.

We will make it so that when installing the latest fragstore package in npm it will make a warning saying so, but I prefer to announce it.

👉 Subscribe to this discussion to find out about the name change.

New features

Breaking changes

  • Remove Store component (now with getStore and callback change it no longer makes sense) #19 (by @aralroca)
  • Callbacks are unified (1 function instead of an object of functions) #19 (by @aralroca)

How to migrate

  1. Remove this component
<Store store={initialStore} callbacks={{ cart: onCartUpdate }}>
</Store>
  1. Use the store variable inside createStore:
const { useStore, getStore } = createStore(initialStore)
// Or if you need it to loading dynamically use the getStore helper:
const [, setStore] = getStore()
setStore(store => ({ ...store, ...initialStore }))
  1. Use a callback inside createStore:
const { useStore, getStore } = createStore(initialStore, onStoreUpdate)

function onStoreUpdate({ path, ...rest }) {
  if(path.startsWith('cart')) onCartUpdate(...rest)
}
// Or if you want the event to be cleared when the component unmounts, use useStore:
const [cart, setCart] = useStore.cart(initialCartValue, onCartUpdate)