Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'ember-local-storage' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
},
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'));
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;
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) {
/* 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'
});
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',
import Controller from '@ember/controller';
import { storageFor } from 'ember-local-storage';
export default Controller.extend({
settings: storageFor('settings'),
actions: {
toggleWelcomeMessage() {
this.toggleProperty('settings.welcomeMessageSeen');
}
}
});
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);
}
}
});
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!");
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')){
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();