Make sure you have a modern-ish version of Node.js installed.
On your CLI type:
npx https://gist.github.com/opauloh/4c615cc5bfec6f8891a94a9ea6c0d090
Connect to it from a client, e.g. netcat or similar: nc localhost 3000
// Note: this is a very basic version, it only checks for files in the server/index.ts path and for imports that ends with Plugin such as TestPlugin | |
import type { Rule } from 'eslint'; | |
export const EnforceServerPluginAsyncImportRule: Rule.RuleModule = { | |
meta: { | |
fixable: 'code', | |
docs: { | |
url: 'https://github.com/elastic/kibana/blob/main/packages/kbn-eslint-plugin-imports/README.mdx', | |
}, |
Make sure you have a modern-ish version of Node.js installed.
On your CLI type:
npx https://gist.github.com/opauloh/4c615cc5bfec6f8891a94a9ea6c0d090
Connect to it from a client, e.g. netcat or similar: nc localhost 3000
// Add a todo | |
const { mutate: createMutate } = useMutation(postAddTodo, { | |
// When mutate is called: | |
onMutate: async (todo) => { | |
// Cancel any outgoing refetches (so they don't overwrite our optimistic update) | |
await queryClient.cancelQueries('todos'); | |
// Build a new todo object, only the necessary fields to show in the UI | |
const newTodo: Todo = { | |
_id: todo.id, |
// Add a todo | |
const { mutate: createMutate } = useMutation(postAddTodo, { | |
// When mutate is called: | |
onMutate: async (todo) => { | |
// Cancel any outgoing refetches (so they don't overwrite our optimistic update) | |
await queryClient.cancelQueries('todos'); | |
// Build a new todo object, only the necessary fields to show in the UI | |
const newTodo: Todo = { | |
_id: todo.id, |
const { mutate: createMutate } = useMutation(postAddTodo, { | |
// When mutate is called: | |
onMutate: async (todo) => { | |
// Cancel any outgoing refetches (so they don't overwrite our optimistic update) | |
await queryClient.cancelQueries('todos'); | |
// Snapshot the previous value | |
const previousTodos = queryClient.getQueryData('todos'); | |
// Build a new todo object, only the necessary fields to show in the UI |
// Add a todo | |
const { mutate: createMutate } = useMutation(postAddTodo, { | |
onError: (error: any, variables) => { | |
notifications.toasts.addDanger( | |
`Error: ${error.message} when attempting to insert ${variables.description}` | |
); | |
}, | |
onSuccess: (res: any) => { | |
// refetch the todo list: | |
queryClient.invalidateQueries('todos') |
const generateTriangleTemplate = (rowsQty) => { | |
return [...Array(rowsQty)] | |
.reduce((prev, _, idx) => { | |
prev = prev.concat([[...Array(idx + 1)]]); | |
return prev; | |
}, []) | |
.map((row) => { | |
let lastColumn = row.length - 1; | |
row[0] = 1; |
/* | |
Reference: https://kentcdodds.com/blog/how-to-give-rendering-control-to-users-with-prop-getters | |
*/ | |
const PropGetterExample = ({ initialValue, handleOnChange, handleOnBlur }) => { | |
const getProps = (slug) => ({ | |
value: initialValue[slug], | |
onChange: (val) => handleOnChange(val, slug), | |
onBlur: handleOnBlur, | |
name: slug, |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |