npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-cordova-storage

v1.1.3

Published

Read and write data as persistent as possible (localStorage/nativeStorage)

Downloads

4

Readme

ember-cordova-storage

Reads and writes appSettings with the most persistent and secure available option in a promise-based manner.

In cordova-application it uses cordova-plugin-nativestorage to save data in the platform-offered setting key/value-stores. In the browser it just stores data in localStorage.

Things you need to be aware of

Do NOT use this if you wish to store huge amounts of data. Querying data isn't supported. This service is particulary targeted against user-settings you wish to carry over restarts/updates and not caching in general.

Also make sure you are not using the service before deviceReady, or else you will end up using localStorage only (since that is the only thing available) before deviceReady.

Prerequisite

Although this does not rely on cordova at runtime and works fine in the browser, the add-on assumes you are building your application with ember-cordova.

Installation

  • ember install ember-cordova-storage

Usage

Just inject the service and you are ready to start:

export default Ember.Route.extend({
  storage: Ember.inject.service('cordova/storage'),

  setupController() {
    this.get('storage')
      .write('pogchamp', Date.now())
      .then(() => this.get('storage').read('pogchamp'))
      .then((val) => Ember.debug(`Read ${val} for key pogchamp. That was ${Date.now() - val}ms ago`))
      .catch(console.log);
  }
});

write(key, value)

Writes a given value to a key and returns the written value as soon as writing finished via a Promise.

You are free to store strings, ints, objects, booleans, arrays and so on. But be aware that some object-attributes might get missing as the actually stored value will JSON.strinfifyed.

read(key, legacy = false)

Reads a given key (always a string) and returns its value inside a Promise.

With legacy you can toggle if you always wish to use localStorage, even if nativeStorage would be available.

If legacy is set, the value will also be returned as is and not tried to be JSON.parseed. This is because we can not safely make the assumption that legacy values were JSON.strinfifyed in the first place.

If a key did not yet exist, this will return null.

clear()

Removes all keys from the storage. Like.. all of them.. Forever.. No turning back.

remove(key, legacy = false)

Removes the given key from the storage.

With legacy you can toggle if you always wish to clear in localStorage, even if nativeStorage would be available.

Thanks

Some parts of this plugin do use code from ember-cordova-keyboard.