I am storing multiple variables in device storage (NativeScript app) using Eddy's nativescript-secure-storage plugin.
Each call to store a value returns a promise:
this.secureStorage = new SecureStorage();
secureStorage.set({
key: "foo",
value: "val1"
}).then(
function(success) {
//move on to the next one.
});
After multiple values are stored, I need to navigate the app to the home view, but need to confirm the values were successfully stored first.
How can I avoid nesting these calls this (which does work but will not be pretty with many values):
this.secureStorage = new SecureStorage();
secureStorage.set({
key: "foo1",
value: "val1"
}).then(
function(success) {
secureStorage.set({
key: "foo2",
value: "val2"
}).then(
function(success) {
secureStorage.set({
key: "foo3",
value: "val3"
}).then(
function(success) {
//navigate to home view
});
});
});