This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { component$, useStore, useSignal, useTask$ } from '@builder.io/qwik'; | |
// Define the Node type | |
type Node = { | |
id: string; | |
name: string; | |
type: string; | |
tags: string[]; | |
children?: Node[]; | |
attributes?: Record<string, unknown>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { component$, useSignal, useVisibleTask$ } from '@builder.io/qwik'; | |
export const ResumeBrowser = component$(() => { | |
const csr = useSignal(false); | |
// eslint-disable-next-line qwik/no-use-visible-task | |
useVisibleTask$(() => { | |
csr.value = true; | |
}); | |
return csr.value ? <Slot /> : null; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Features */ | |
// - remove cache headers for /q-data.json | |
export const handler = async (event, context) => { | |
try { | |
const [req, res, ctx, target] = eventNormalize(event, context); // 'ctx' is the context object | |
// Your business logic here | |
// Example of modifying the response based on URI | |
if (req.uri.endsWith('/q-data.json')) { | |
res.headers['cache-control'] = 'no-cache'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { readable, writable } = new TransformStream(); | |
fetch('/send?channel=123', method: 'POST', | |
headers: { 'Content-Type': 'text/plain' }, | |
body: readable, | |
}); | |
const response = await fetch('/receive?channel=123'); | |
const response_readable = response.body; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const machine = useConst(() => { | |
return { | |
state: 'off', | |
_machine: undefined, | |
send: $((newState) => { | |
return this._machine ||= noSerialize(createMachine(this))).send(newState) | |
) | |
}; | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { HTMLAttributes, JSXOutput, Signal } from '@builder.io/qwik'; | |
import { | |
Slot, | |
component$ | |
} from '@builder.io/qwik'; | |
import { | |
Link as QwikLink | |
} from '@builder.io/qwik-city'; | |
export function getBaseUrl(base?: string) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getData = server$((myArg) => { | |
console.log(myArg) | |
}); | |
getData(new ServerConfig({ | |
method: 'get' | |
}), myArg) | |
getData(serverConfig({ | |
method: 'get' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { isBrowser } from '@builder.io/qwik/build'; | |
serverOnly(); | |
export function serverOnly() { | |
if (isBrowser) { | |
console.log('SERVER ONLY'); | |
throw new Error( | |
'This module cannot be imported from the Client.' + | |
'It should only be used from the Server.', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"tailwindCSS.experimental.classRegex": [ | |
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"], | |
["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"] | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Qwik | |
Deprecated functions and their replacements | |
Deprecated Replacements | |
useWatch$ useTask$ | |
useMount$ useTask$ | |
useServerMount useTask$ + isServer | |
useClientMount useTask$ + isBrowser | |
useClientEffect useVisibleTask$ | |
useClientEffectQrl useVisibleTask$ | |
useBrowserVisibleTask useVisibleTask$ |
NewerOlder