How to clear amplify.store ()?

I need to clear amplifyjs memory, delete all key values. Smth is similar to localStorage.clear ().

Thanks in advance.

+4
source share
1 answer

The documents for amplification indicate that you can clear (delete) a specific storage key by storing the value nullfor this key:

amplify.store( "MyKeyName", null );

We can get all current storage key names with amplify.store(), and then use jQuery $.eachto view the list and delete (delete) each of the elements currently stored in the amplifyjs memory:

$.each(amplify.store(), function (storeKey) {
    // Delete the current key from Amplify storage
    amplify.store(storeKey, null);
});

, , , - :

amplify.clearStore = function() {
    $.each(amplify.store(), function (storeKey) {
        // Delete the current key from Amplify storage
        amplify.store(storeKey, null);
    });
};

amplify.clearStore();

+6

Source: https://habr.com/ru/post/1543222/


All Articles