Share your advanced knowledge/code with the community.
ljgww
 
Posts: 26
Joined: Thu Mar 26, 2020 5:47 pm

DeleteFile in Local Storage

by ljgww Tue Apr 14, 2020 7:24 pm

I did not find a command to delete 'file' from the LocalStorage in the list of File functions in SB.
I needed this, so I made a little workaround (by not doing anything but interfacing it). Here it is:

Code: Select all
Procedure DeleteFileLocalStorage(Filename.s)
Debug "* DeleteFile: " + Filename
EnableJS
LocalForage.removeItem('sbfs_'+v_filename).then(function() {
    // Run this code once the key has been removed.
    console.log('Key is cleared!');
  }).catch(function(err) {
    // This code runs If there were any errors
    console.log(err);
    });
DisableJS
EndProcedure


Source: https://localforage.github.io/localFora ... removeitem

Of course: if you do this, to be able to see the effect of deleting, you need to refresh the browser window.
Return to Tricks 'n' Tips

Who is online

Users browsing this forum: No registered users and 1 guest