How to use the electron-json-storage.empty function in electron-json-storage

To help you get started, we’ve selected a few electron-json-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 evancohen / smart-mirror / plugins / reminder / controller.js View on Github external
function Reminder($scope, SpeechService, $translate, Focus) {
	const storage = require('electron-json-storage');
    // Service variable
	var remind = {};
    // Flag to check if reminders list is empty
	storage.empty = true;
    // Need to use the callback function because when the service is initialize,
    // the translation service is not set up.
	$translate('reminders.empty').then(function (translation) {
		remind.reminders = [translation];
	});
    // Check if reminder storage already exists
	storage.has('sm-reminder', function (error, hasKey) {
		if (error) throw error;
		if (hasKey) {
            // Flag to check if reminders list is empty
			remind.empty = false;
			storage.get('sm-reminder', function (error, data) {
				if (error) throw error;
				remind.reminders = data.reminders;
			});
		}