Sometimes we want to trigger some actions or pass some data to other components no matter where they are placed inside the page.

To do this, we can use a fouita builtin version of svelte stores.

<!-- Cm1.svelte -->
 let data = {name: 'fetched data from server'}
 window.Fouita.Store('myData', data)

We can use the $ sign or subscribe function to access data like svelte store autosubscription

 $: data = window.Fouita.Store('myData')


We can update the store using the assign operator, or using the set method

 let data = window.Fouita.Store('myData')
 data = {name: "new data!"}

 // or we can use set
 data.set({name: "new data set"})

 // using update
 data.update(d => { = "new data updated"
  return d

Persist data to localStorage

We can also save data to localStorage directly from the store object using the "save" method

let userStore = window.Fouita.Store('userInfo', {}){email: "[email protected]", token: "123456789"})

Now even when we refresh the page the user will still accessible, to delete it we can use "clear" method