本文整理汇总了TypeScript中lodash.debounce函数的典型用法代码示例。如果您正苦于以下问题:TypeScript debounce函数的具体用法?TypeScript debounce怎么用?TypeScript debounce使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debounce函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: constructor
/**
* Constructor
*
* @param {ElementRef} elementRef
* @param {FuseConfigService} _fuseConfigService
* @param {Platform} _platform
* @param {Router} _router
*/
constructor(
public elementRef: ElementRef,
private _fuseConfigService: FuseConfigService,
private _platform: Platform,
private _router: Router
)
{
// Set the defaults
this.isInitialized = false;
this.isMobile = false;
// Set the private defaults
this._enabled = false;
this._debouncedUpdate = _.debounce(this.update, 150);
this._options = {
updateOnRouteChange: false
};
this._unsubscribeAll = new Subject();
}
开发者ID:,项目名称:,代码行数:27,代码来源:
示例2: constructor
constructor(vim: any, host: TypeScriptServerHost) {
this._vim = vim;
this._host = host;
this._updateHighlightFunction = _.debounce((file) => {
this._host._makeTssRequest<void>("navbar", {
file: file
}).then((val: any) => {
console.log("Got highlighting result: " + JSON.stringify(val));
var syntaxHighlighter = new SyntaxHighlighter();
var highlighting = syntaxHighlighter.getSyntaxHighlighting(val);
this._vim.setSyntaxHighlighting(highlighting);
console.log("Setting syntax highlighting: " + JSON.stringify(highlighting));
}, (err) => {
console.error(err);
});
}, 100);
}
开发者ID:extr0py,项目名称:vim-electrify-typescript-completion,代码行数:21,代码来源:SyntaxHighlightManager.ts
示例3: data
export function createMixin<T extends object>(name: string, initialData: T) {
// @vue/component
return {
data() {
return {
displayState: _.cloneDeep(initialData)
};
},
watch: {
displayState: {
handler: _.debounce((value: any) => {
localStorage.setItem(name, JSON.stringify(value));
}, 500),
deep: true
}
},
mounted(this: { displayState: T }) {
let storedData: T | undefined;
const jsonString = localStorage.getItem(name);
if (jsonString) {
try {
storedData = JSON.parse(jsonString);
} catch (_) {
// leave storedData undefined
localStorage.removeItem(name);
}
}
const currentData = this.displayState;
if (storedData !== undefined) {
for (const key in currentData) {
const value = storedData[key];
if (value !== undefined) {
currentData[key] = value;
}
}
}
localStorage.setItem(name, JSON.stringify(currentData));
}
};
}
开发者ID:wonderful-panda,项目名称:inazuma,代码行数:40,代码来源:displayState.ts
示例4: WatchExecutor
.flatMap(job => {
if (this._runner === undefined) {
const runner = new WatchExecutor(job, this._dialog);
this._runner = runner;
// FIXME how to stop the runner
const cbk = _.debounce(path => runner.run(), this._debounceTime);
this._watcher = chokidar.watch(this._def.files, {
// ignored: /../,
// persistent: true
});
this._watcher.on('error', err => {
console.error('Error during watch', err);
});
this._watcher.on('ready', () => {
LISTEN_EVENTS.forEach(eventName => this._watcher.on(eventName, cbk));
});
return runner.subject;
} else {
return this._runner.subject;
}
});
开发者ID:Kineolyan,项目名称:Jarvis,代码行数:22,代码来源:WatchJob.ts
示例5: eventChannel
const resizeChan = eventChannel((emit) => {
artboard.mount.contentWindow.addEventListener("resize", debounce(emit, RESIZE_TIMEOUT));
return () => {};
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:4,代码来源:artboard.ts
示例6: function
link: function($scope, elem) {
const $input = $(inputTemplate);
const segment = $scope.segment;
const $button = $(segment.selectMode ? selectTemplate : linkTemplate);
let options = null;
let cancelBlur = null;
let linkMode = true;
const debounceLookup = $scope.debounce;
$input.appendTo(elem);
$button.appendTo(elem);
$scope.updateVariableValue = function(value) {
if (value === '' || segment.value === value) {
return;
}
value = _.unescape(value);
$scope.$apply(function() {
const selected = _.find($scope.altSegments, { value: value });
if (selected) {
segment.value = selected.value;
segment.html = selected.html || selected.value;
segment.fake = false;
segment.expandable = selected.expandable;
if (selected.type) {
segment.type = selected.type;
}
} else if (segment.custom !== 'false') {
segment.value = value;
segment.html = $sce.trustAsHtml(value);
segment.expandable = true;
segment.fake = false;
}
$scope.onChange();
});
};
$scope.switchToLink = function(fromClick) {
if (linkMode && !fromClick) {
return;
}
clearTimeout(cancelBlur);
cancelBlur = null;
linkMode = true;
$input.hide();
$button.show();
$scope.updateVariableValue($input.val());
};
$scope.inputBlur = function() {
// happens long before the click event on the typeahead options
// need to have long delay because the blur
cancelBlur = setTimeout($scope.switchToLink, 200);
};
$scope.source = function(query, callback) {
$scope.$apply(function() {
$scope.getOptions({ $query: query }).then(function(altSegments) {
$scope.altSegments = altSegments;
options = _.map($scope.altSegments, function(alt) {
return _.escape(alt.value);
});
// add custom values
if (segment.custom !== 'false') {
if (!segment.fake && _.indexOf(options, segment.value) === -1) {
options.unshift(segment.value);
}
}
callback(options);
});
});
};
$scope.updater = function(value) {
if (value === segment.value) {
clearTimeout(cancelBlur);
$input.focus();
return value;
}
$input.val(value);
$scope.switchToLink(true);
return value;
};
$scope.matcher = function(item) {
let str = this.query;
if (str[0] === '/') {
str = str.substring(1);
}
if (str[str.length - 1] === '/') {
str = str.substring(0, str.length - 1);
//.........这里部分代码省略.........
开发者ID:gzq0616,项目名称:grafana,代码行数:101,代码来源:metric_segment.ts
示例7: constructor
constructor(destination: Subscriber<T>, duration: number, options: DebounceOptions) {
super(destination);
this._duration = duration;
this._method = debounce(bind(this._dispatchNext, this), duration, options);
}
开发者ID:OmniSharp,项目名称:atom-languageclient,代码行数:5,代码来源:LodashDebounce.ts
示例8: _saveWindowPosition
function _saveWindowPosition(sync: boolean, win: Electron.BrowserWindow) {
const size = win.getSize();
const pos = win.getPosition();
shellConfig.set("window.posX", pos[0]);
shellConfig.set("window.posY", pos[1]);
shellConfig.set("window.width", size[0]);
shellConfig.set("window.height", size[1]);
shellConfig.set("window.maximized", win.isMaximized());
if (sync) {
shellConfig.saveSync();
} else {
shellConfig.save();
}
}
const saveWindowPositionSync = _.partial(_saveWindowPosition, true);
const saveWindowPosition = _.debounce(_.partial(_saveWindowPosition, false), 100);
// Quit when all windows are closed.
let windowAllClosed = false;
app.on("window-all-closed", function () {
windowAllClosed = true;
setTimeout(app.quit, 500);
});
app.on("before-quit", function (event) {
if (!windowAllClosed) {
event.preventDefault();
const windows = BrowserWindow.getAllWindows();
windows.forEach((win) => win.close());
}
开发者ID:zaggino,项目名称:brackets-electron,代码行数:31,代码来源:main.ts
示例9: clearInterval
clearInterval(interval);
} else {
let goal;
if (scrollingDown) {
goal = Math.min(y, scrollTop + step);
} else {
goal = Math.max(y, scrollTop - step);
}
stepsDone++;
scrollTop = goal;
scrollElement(parent, goal);
}
}, SCROLLING_INTERVAL);
};
smoothScrollTop = debounce(smoothScrollTop, SCROLLING_DURATION, { leading: true });
export function scrollToElement(
element: Element,
options: {
topOffset?: number;
bottomOffset?: number;
parent?: Element;
smooth?: boolean;
}
): void {
const opts = { topOffset: 0, bottomOffset: 0, parent: window, smooth: true, ...options };
const { parent } = opts;
const { top, bottom } = element.getBoundingClientRect();
开发者ID:flopma,项目名称:sonarqube,代码行数:30,代码来源:scrolling.ts
示例10: registerShortcuts
function registerShortcuts(menuItem: MenuItemOptions) {
if (menuItem.accelerator) {
if (null == systemShortcuts.find((x) => x === menuItem.accelerator)) {
globalShortcut.register(menuItem.accelerator, menuItem.click as Function);
}
}
if (Array.isArray(menuItem.submenu)) {
menuItem.submenu.forEach((i) => registerShortcuts(i));
}
}
const __refreshMenu = _.debounce(function () {
Menu.setApplicationMenu(Menu.buildFromTemplate(_.cloneDeep(menuTemplate)));
globalShortcut.unregisterAll();
const mainWindow = shell.getMainWindow();
if (mainWindow.isFocused()) {
menuTemplate.forEach((menuItem) => registerShortcuts(menuItem));
}
}, 100);
function _refreshMenu(callback?: () => void) {
__refreshMenu();
if (callback) {
process.nextTick(callback);
}
}
function _findMenuItemPosition(
id: string, where: MenuItemOptions[] = menuTemplate, whereId: string = ""
): [string, number] | null {
const result = _.find(where, { id });
开发者ID:Real-Currents,项目名称:brackets,代码行数:31,代码来源:app-menu.ts
注:本文中的lodash.debounce函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论