# How to get the LocalStorage value out of promise scope

**URL:** <https://forum.ionicframework.com/t/how-to-get-the-localstorage-value-out-of-promise-scope/57296>\
**Category:** ionic-v3\
**Created:** [July 12, 2016, 3:18pm UTC](https://forum.ionicframework.com/t/how-to-get-the-localstorage-value-out-of-promise-scope/57296 "2016-07-12T15:18:20Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [May 16, 2017, 8:29pm UTC](https://forum.ionicframework.com/t/how-to-get-the-localstorage-value-out-of-promise-scope/57296/20 "2017-05-16T20:29:12Z")

</div>

Is there a reason you’re splitting all these things up? I would just do this:

```auto
export interface Preferences {
  playContinuously: boolean;
  keepMediaPlaying: boolean;
  playWhileHidden: boolean;
}

export class PreferenceService {
  preferences: Promise<Preferences>;

  constructor(private _storage: Storage) {
    this.preferences = _storage.ready().then(() => _storage.get('preferences'));
  }

  setPreferences(prefs: Preferences): Promise<void> {
    return this._storage.set('preferences', prefs).then(() => {
      this.preferences = Promise.resolve(prefs);
    });
  }
}

export class SettingsPage {
  preferences: Preferences;

  constructor(private _prefService: PreferenceService) {
    _prefService.preferences.then(prefs => this.preferences = prefs);
  }

  save(): void {
    this._prefService.setPreferences(this.preferences);
  }
}

```

---

_[View the full topic](https://forum.ionicframework.com/t/how-to-get-the-localstorage-value-out-of-promise-scope/57296)._
