Skip to content

Instantly share code, notes, and snippets.

View majames's full-sized avatar
👨‍💻

Michael James majames

👨‍💻
View GitHub Profile
@tomhicks
tomhicks / useTaskQueue.ts
Created January 11, 2021 11:41
React Hook for queueing and processing async tasks sequentially
function useTaskQueue(params: {
shouldProcess: boolean
}): {
tasks: ReadonlyArray<Task>
isProcessing: boolean
addTask: (task: Task) => void
} {
const [queue, setQueue] = React.useState<{
isProcessing: boolean
tasks: Array<Task>
@lencioni
lencioni / tsserverWithEventsPlugin.ts
Last active October 19, 2024 02:14
TypeScript Server Plugin with custom project event handler
import * as ts_module from 'typescript/lib/tsserverlibrary';
/** Log to the TS Server log */
function log(info: ts.server.PluginCreateInfo, message: string) {
info.project.projectService.logger.info(`[My TS Server Plugin] ${message}`);
}
// https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin
export default function init({ typescript: ts }: { typescript: typeof ts_module }) {
return {