Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49083

How to add Capacitor Storage value to Observable

$
0
0

Hi,
I have values stored with capacitor storage and retrieve them with the following code:

export async function getStorage(key: string): Promise<any> {
  const item = await Plugins.Storage.get({ key });
  return JSON.parse(item.value);
}

and then I have a method:

async getretrievedValue() {
    this.retrievedValue = await getStorage("retrievedValue");
    console.log(this.retrievedValue);
}

so this all works, but how do I set this as an Observable so that it will be available throughout the app and also automatically updates when the value changes?

Thank you for your help

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 49083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>