How to use ember-local-storage - 10 common examples

To help you get started, we’ve selected a few ember-local-storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hummingbird-me / hummingbird-client / app / controllers / users / library.js View on Github external
},
  direction: {
    defaultValue: 'desc',
    refresh: true
  },
  title: {
    defaultValue: '',
    refresh: true
  },
  preserveScrollPosition: {
    defaultValue: true
  }
});

export default Controller.extend(queryParams.Mixin, {
  cache: storageFor('last-used'),
  libraryEntries: concat('model.taskInstance.value', 'model.paginatedRecords'),
  filteredLibraryEntries: filterBy('libraryEntries', 'isDeleted', false),

  init() {
    this._super(...arguments);
    set(this, 'mediaTypes', ['anime', 'manga']);
    set(this, 'statuses', ['all', ...LIBRARY_STATUSES]);
    set(this, 'layoutStyle', get(this, 'cache.libraryLayout') || 'grid');
  },

  queryParamsDidChange({ shouldRefresh, changed }) {
    // save to cache
    if (get(this, 'session').isCurrentUser(get(this, 'user'))) {
      const cache = get(this, 'cache');
      if ('media' in changed) {
        set(cache, 'libraryType', get(changed, 'media'));
github hummingbird-me / hummingbird-client / app / routes / application.js View on Github external
import { get, set } from '@ember/object';
import { inject as service } from '@ember/service';
import { scheduleOnce } from '@ember/runloop';
import { storageFor } from 'ember-local-storage';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
import moment from 'moment';

export default Route.extend(ApplicationRouteMixin, {
  features: service(),
  head: service('head-data'),
  headTagsService: service('head-tags'),
  intl: service(),
  metrics: service(),
  moment: service(),
  raven: service(),
  cache: storageFor('last-used'),
  local: storageFor('local-cache'),

  // If the user is authenticated on first load, grab the users data
  beforeModel() {
    const session = get(this, 'session');
    if (get(session, 'isAuthenticated')) {
      return this._getCurrentUser();
    }
    return get(this, 'features').fetchFlags();
  },

  title(tokens) {
    const base = 'Kitsu';
    // If the route hasn't defined a `titleToken` then try to grab the route
    // name from the `titles` table in translations.
    const hasTokens = tokens && tokens.length > 0;
github hummingbird-me / hummingbird-client / app / routes / application.js View on Github external
import { inject as service } from '@ember/service';
import { scheduleOnce } from '@ember/runloop';
import { storageFor } from 'ember-local-storage';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
import moment from 'moment';

export default Route.extend(ApplicationRouteMixin, {
  features: service(),
  head: service('head-data'),
  headTagsService: service('head-tags'),
  intl: service(),
  metrics: service(),
  moment: service(),
  raven: service(),
  cache: storageFor('last-used'),
  local: storageFor('local-cache'),

  // If the user is authenticated on first load, grab the users data
  beforeModel() {
    const session = get(this, 'session');
    if (get(session, 'isAuthenticated')) {
      return this._getCurrentUser();
    }
    return get(this, 'features').fetchFlags();
  },

  title(tokens) {
    const base = 'Kitsu';
    // If the route hasn't defined a `titleToken` then try to grab the route
    // name from the `titles` table in translations.
    const hasTokens = tokens && tokens.length > 0;
    if (hasTokens === false) {
github kuzzmi / ember-express-blog / client / app / components / post-edit-form.js View on Github external
/* globals CodeMirror */
/* globals hljs */

import Ember from 'ember';
import config from '../config/environment';
import { storageFor } from 'ember-local-storage';

const cm = CodeMirror;

export default Ember.Component.extend({
    store: Ember.inject.service(),
    api: Ember.inject.service(),
    backup: storageFor('postBackup'),
    editor: null,
    preview: '',
    isPreview: false,
    images: [],

    /* events */
    didInsertElement() {
        let self = this;
        this._super(...arguments);
        let myTextarea = this.$('#editor-body')[0];
        let editor = cm(myTextarea, {
            value: this.get('post.markdown') || '',
            mode: 'markdown',
            lineWrapping: true,
            keyMap: 'vim'
        });
github hummingbird-me / hummingbird-client / app / components / stream-feed / list.js View on Github external
export default Component.extend(Pagination, {
  readOnly: false,
  showFollowingFilter: false,
  allFeedItems: concat('feed', 'paginatedRecords'),
  ajax: service(),
  features: service(),
  headData: service(),
  headTags: service(),
  notify: service(),
  store: service(),
  queryCache: service(),
  metrics: service(),
  raven: service(),
  streamRealtime: service(),
  lastUsed: storageFor('last-used'),

  feedId: getter(function() {
    return `${get(this, 'streamType')}:${get(this, 'streamId')}`;
  }),

  getFeedData: task(function* (limit = 10) {
    const { streamType: type, streamId: id } = getProperties(this, 'streamType', 'streamId');
    const kind = get(this, 'filter');
    const options = {
      type,
      id,
      include: [
        // activity
        'media,actor,unit,subject,target',
        // posts (and comment system)
        'target.user,target.target_user,target.spoiled_unit,target.media,target.target_group,target.uploads',
github funkensturm / ember-local-storage / tests / dummy / app / controllers / storage-for.js View on Github external
import Controller from '@ember/controller';
import { storageFor } from 'ember-local-storage';

export default Controller.extend({
  settings: storageFor('settings'),

  actions: {
    toggleWelcomeMessage() {
      this.toggleProperty('settings.welcomeMessageSeen');
    }
  }
});
github funkensturm / ember-local-storage / tests / dummy / app / controllers / post.js View on Github external
import Ember from 'ember';
import { storageFor } from 'ember-local-storage';

export default Ember.Controller.extend({
  postStats: storageFor('stats', 'model'),

  actions: {
    countUp() {
      this.incrementProperty('postStats.counter');
    },
    resetCounter() {
      this.set('postStats.counter', 0);
    }
  }
});
github blandman / HappyLeaf / app / components / home-screen.js View on Github external
import Ember from 'ember';

import subscribe from 'ember-cordova-events/utils/subscribe';
import { translationMacro as t } from "ember-i18n";
import { storageFor } from 'ember-local-storage';

export default Ember.Component.extend({
  i18n: Ember.inject.service(),
  tagName: "main",
  connectionManager: Ember.inject.service('connection-manager'),
  storageManager: Ember.inject.service('storage-manager'),
  logManager: Ember.inject.service('log-manager'),
  dataManager: Ember.inject.service('data-manager'),
  flowManager: Ember.inject.service('flow-manager'),
  cordova: Ember.inject.service('ember-cordova/events'),
  settings: storageFor('settings'),
  history: storageFor('history'),
  router: null,
  openNav: false,

  homeLocked: true,

  messagesReceived: [],
  messagesWithoutData: [],

  lastSave: null,
  lastMessageTime: null,

  requesting: false,

  isReady: subscribe('cordova.deviceready', function() {
    console.log("Device is ready!");
github blandman / HappyLeaf / app / services / log-manager.js View on Github external
import Ember from 'ember';
import { storageFor } from 'ember-local-storage';

var currentVersion = "(fresh install)";
export default Ember.Service.extend({
  settings: storageFor('settings'),
  dataManager: Ember.inject.service('data-manager'),
  
  logText: "HappyLeaf Version " + currentVersion + "\r\n",
  logFull: "HappyLeaf Version " + currentVersion + "\r\n",

  historyLogName: null,
  canLogName: null,

  betaDirectory: null,
  happyLeafDir: null,

  init() {
    this._super();
    this.set('historyLogName', moment().format("MM-DD-YYYY_HH-mm") + "-history.json");
    this.set('canLogName', moment().format("MM-DD-YYYY_HH-mm") + "-OBD-log.txt");
    if(this.get('settings.settings')){
github hummingbird-me / hummingbird-client / app / controllers / dashboard.js View on Github external
import Controller from 'ember-controller';
import service from 'ember-service/inject';
import computed from 'ember-computed';
import get from 'ember-metal/get';
import set from 'ember-metal/set';
import observer from 'ember-metal/observer';
import { storageFor } from 'ember-local-storage';

const MAGIC_NUMBER = 7;

export default Controller.extend({
  lastUsed: storageFor('last-used'),
  session: service(),

  streamId: computed('streamType', 'session.hasUser', {
    get() {
      return get(this, 'streamType') === 'global' ? 'global' : get(this, 'session.account.id');
    }
  }).readOnly(),

  updateStreamType: observer('session.hasUser', 'session.account.followingCount', function() {
    const defaultType = this._getDefaultType();
    set(this, 'streamType', get(this, 'lastUsed.feedType') || defaultType);
  }),

  init() {
    this._super(...arguments);
    const defaultType = this._getDefaultType();

ember-local-storage

The addon provides an ember-data adapter and a storageFor computed property that persists the changes to localStorage or sessionStorage.

MIT
Latest version published 10 months ago

Package Health Score

58 / 100
Full package analysis

Popular ember-local-storage functions