I am using EventBus. My code is below.
app.js
window.EventBus = new Vue();
Below is the code that Emit
EventBus.$emit('emitted', {
SomeProperty: SomeData,
});
Below is the code to retrieve the emitted data
EventBus.$on('emitted', id => {
});
Is there any way to store the emitted data once the emitted data is fetched? I am trying to search if there is any way to save the emitted data somewhere?
You have two options: Arrange with the owners that they store the data and make it available for verification purposes, for at least the obligatory period of storage (ten years). You can then simply refer to their storage. Try to arrange a local copy, that you yourself can store for the required period. VIII.
For sharing, data should be stored as raw as possible (if usable in that form) along with documentation to help comprehend and reuse it. In both of these cases you should include: A variable list or code book explaining the variables in your data.
Anyways, local data storage does not have to be reliant on the Internet in order to retrieve information. This means is can be a faster and more secure way to save all your data. Of course, transferring all of your locally stored files over once you purchase a new machine can be laborious and time-consuming.
Try to predict how large your data store will need to be in the future. There are many types of encryption you can use. It is crucial to ensure the safety of your customers’ and your business data. Data leaks, damage or theft can ruin your company. Protect your vital information by using the best authentication mechanism available.
To save data and share between components, use vuex
To save data in localstorage, for convenience you can use vue-ls
Since you're using Vue with Laravel:
// Your event bus
const EventBus = new Vue()
// The main Vue instance for your app
const app = new Vue({
// ALL YOUR APP LOGIC GOES HERE...
methods: {
fetchData (params) {
// this is the method you use to fetch data, here you can use a library
// like axios to query your api and return the result
return axios.get('/api/someData', { params })
}
},
// Every time your app is loaded, it executes the created() hook to retrieve
// previously stored data from localStorage.
// Depending on your needs, you can use mounted() hook instead.
created () {
// Attach the listener to store someData in localStorage
EventBus.$on('someData', data => window.localStorage.setItem('someData', data))
// check for stored someData
const someData = window.localStorage.getItem('someData')
if (someData) {
// do something with someData
}
else {
// there is no someData stored, so fetch and store ($emit)
this.fetchData()
.then(response => {
if (response.data.someData) {
EventBus.$emit('someData', response.data.someData)
}
})
}
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With