Where is Storage and LocalStorage in rc0?

I was able to implement the Ionic2 Storage too. Since I posted here above a solution with LocalForage, here how I switched to Storage:

1_Remove localforage

sudo npm remove localforage --save

2_Remove localforage typescript definition

sudo npm remove @types/localforage --save-dev

3_Install (or install again) the Ionic storage

sudo npm install @ionic/storage --save --save-exact

4_As @apreg pointed out, declare Storage in your providers of app.modules.ts

import { Storage } from '@ionic/storage';

...

@NgModule({
   ...
  providers: [Storage]
})

5_Change or create your code

 import {Injectable} from '@angular/core';
 import {Storage} from '@ionic/storage';
 
 @Injectable()
 export class MyService {
  
      constructor(public storage:Storage) {
     }
  
    save(data: any): Promise<any> {
       return this.storage.set('my_key', data);
    }
  
   retrieve(): Promise<any> {
    return this.storage.get('my_key');
   }

    clear(): Promise<void> {
    return this.storage.clear();
  }

}

P.S.: References

1 Like