I am using ionic 2 framework and I have tried using local storage to store a network status
this.local = new Storage(LocalStorage);
this.local.set("status", this.status);
There are 2 values that, "Strong" and "Weak" that can be assigned to status dynamically.
I am able to get my the initial value of my local storage "status" value on initialization of every page.
toCheckStatus();
function toCheckStatus()
{
self.local = new Storage(LocalStorage);
self.local.get('status').then((value) =>
{
console.log("status", value);
});
}
this will return me a "Strong" or "Weak", which is what I want, but is there any methods or event to dynamically (On "status" value change) call "toCheckStatus()" function?
Workflow Example (pseudo-code):
- On application start -> Check internet status (Background will keep checking and update local-storage value)
- Store status to local-storage
- Call a function to get the value (How to dynamically call this function when my value change, is there any method?)
- If Status is Weak -> Show Weak Icon
- If Status is Strong -> Show Strong icon