[QUESTION] How to distinguish between a successful or invalid store?
Question
Hi! I'm integrating GrapesJS ina laravel app and so far so good.
After configuring remote load and storage, I'm trying to show a notification after any store (auto or manual).
Following the API documentation I got that easily:
editor.on('storage:end:store', () => { showNotification() });
This works fine. Then I tried to show a different notification in case of a remote error like this:
editor.on('storage:error:store', () => { showErrorNotification() });
It's working, but in case of an error it shows both the notifications. I think there is no storage:success:store event. Is there any way to achive this with the available events?
Thanks and keep on the excelent work!
Answers (1)
@csb346 yes, you're right, there is no storage:success:store, the event storage:end:store is correctly called even in case of errors, but being the last called you can make use of a flag variable
let error;
editor.on('storage:error:store', () => {
showErrorNotification();
error = 1;
});
editor.on('storage:end:store', () => {
!error && showNotification();
error = 0;
});
Related Questions and Answers
Continue research with similar issue discussions.
Issue #849
Ability to unload and destroy the editor instance or reload the config options?
In my use case, I'm trying to change the store and load URLs used by the remote storage manager dynamically. As far as I can tell, the edit...
Issue #2512
[Question] GrapesJS in a VueJS app
I'm building a VueJS app and would like to use GrapesJS inside the app (and I'm NOT trying to use VueJS inside GrapesJS). I've searched and...
Issue #963
[Question] Create PHP endopoint to remote Storage Manager
Hello. I'm integrating GrapeJS with PHP (CodeIgniter) and I saw that there are others who do this. But I looked in the documentation and ch...
Issue #3041
Question: How to render the website in frontend after designing it in the editor?
Hi all, I am wondering how to render the website with our own components designed by the editor into frontend? I cannot find any info about...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.