本文整理匯總了TypeScript中electron-json-storage.get函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript get函數的具體用法?TypeScript get怎麽用?TypeScript get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了get函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
$('body').on('click', '#db-dialog #add-btn', function(event) {
let $form = $('#db-dialog form'),
$name = $form.find('input[name="Name"]'),
$url = $form.find('input[name="MongoDB URL"]'),
$resp = $form.find('.response');
if ($name.val() === '') {
pushResponse($resp, 'Name field cannot be empty.');
return;
}
storage.get('dbs', function(error, dbs) {
if (error) {
console.error(error);
} else {
if (_.contains(_.map(dbs, (db: DBEntry) => { return db.name; }), $name.val())) {
pushResponse($resp, 'Key already exists.');
} else {
if (_.isEmpty(dbs)) {
dbs = [];
}
dbs.push({
name: $name.val(),
url: $url.val()
});
storage.set('dbs', dbs, function(error) {
if (error) {
console.error(error);
} else {
pushResponse($resp, 'Entry added successfully.');
}
});
}
}
});
});
示例2: function
fs.readFile(__dirname + '/../templates/email.mst', 'utf-8', (error, template) => {
if (error) {
console.error(error);
} else {
tmp_files.push(tmpobj);
let rendered = Mustache.render(template, {email: tmpobj.name});
$('.content').html(rendered);
storage.get('queries', function(error, queries) {
if (error) {
console.error(error);
} else {
let hound = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
identify: (q) => { return q.name; },
local: queries
});
$('input[name="query"]').typeahead({
hint: true,
minLength: 0,
highlight: true
}, {
name: 'queries',
display: 'name',
source: hound
});
}
});
}
});
示例3: function
click: function() {
storage.get('mailgun', function(error, data) {
if (error) {
console.error(error);
} else {
popup.open('mailgun-modal.mst', 'mailgun-dialog', data);
}
});
}
示例4: function
fs.readFile(__dirname + '/../templates/index.mst', 'utf-8', (error, template) => {
if (error) {
console.error(error);
} else {
storage.get('templates', function(error, templates) {
if (error) {
console.error(error);
} else {
let rendered = Mustache.render(template, {templates: templates});
$('.content').html(rendered);
}
});
}
});
示例5: function
$('body').on('click', '#query-dialog #add-btn', function(event) {
let $form = $('#query-dialog form'),
$name = $form.find('input[name="Name"]'),
$collection = $form.find('input[name="Collection"]'),
$query = $form.find('textarea[name="Query"]'),
$resp = $form.find('.response');
if ($name.val() === '') {
return pushResponse($resp, 'Name field cannot be empty.');
}
if ($collection.val() === '') {
return pushResponse($resp, 'Collection field cannot be empty.');
}
try {
JSON.parse($query.val());
} catch (e) {
return pushResponse($resp, 'Invalid query.');
}
storage.get('queries', function(error, queries) {
if (error) {
console.error(error);
} else {
if (_.contains(_.map(queries, (q: QueryEntry) => { return q.name; }), $name.val())) {
pushResponse($resp, 'Key already exists.');
} else {
if (_.isEmpty(queries)) {
queries = [];
}
queries.push({
name: $name.val(),
collection: $collection.val(),
query: $query.val()
});
storage.set('queries', queries, function(error) {
if (error) {
console.error(error);
} else {
pushResponse($resp, 'Entry added successfully.');
}
});
}
}
});
});
示例6: reject
storage.has(TWITTER_CREDENTIALS_KEY, (err, hasKey) => {
if (err) {
reject(err)
}
if (hasKey) {
storage.get(TWITTER_CREDENTIALS_KEY, (err, result) => {
if (err) {
reject(err)
}
resolve(result as TwitterCredentials)
})
return
}
this.fetchTwitterCredentials()
.then(result => {
storage.set(TWITTER_CREDENTIALS_KEY, result, (err) => {
if (err) {
reject(err)
}
resolve(result as TwitterCredentials)
})
})
})
示例7: Promise
return new Promise((resolve, reject) => {
get(CONFIG, (error: any, data: SettingState) => error ? reject(error) : resolve(data));
});
示例8: function
/// <reference path="../../typings/index.d.ts" />
/// <reference path="../../definitions/index.d.ts" />
import * as $ from 'jquery';
import * as storage from 'electron-json-storage';
import {close} from './popup';
export let api_key = '';
export let domain = '';
storage.get('mailgun', function(error, data) {
if (error) {
console.error(error);
} else {
api_key = data.api_key;
domain = data.domain;
}
});
$('body').on('click', '#mailgun-dialog .button#save', function(event) {
api_key = $('#mailgun-dialog input[name="API Key"]').val();
domain = $('#mailgun-dialog input[name="Domain"]').val();
storage.set('mailgun', { api_key: api_key, domain: domain}, function(error) {
if (error) {
console.error(error);
}
});
close();
});
示例9: require
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
import { bootstrap } from '@angular/platform-browser-dynamic'
import { provideStore } from '@ngrx/store'
import { runEffects } from '@ngrx/effects'
import { Counter, counterReducer } from "./components/counter"
import { ElectronSaverEffect, STATE_PROP } from './helpers/hot-reloader'
import { remote } from 'electron'
const storage: any = require('electron-json-storage')
storage.get(STATE_PROP, (err: any, data: any) => {
console.log(data)
bootstrap(Counter, [
provideStore({ counter: counterReducer }, data),
runEffects(ElectronSaverEffect)
])
})