Skip to content

fix: deprecated event$ #7407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hip-lemons-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': patch
---

Deprecated event$, it will be removed in v2. Instead, use `$()`, and inside the function add `if (isServer) { return; }`
4 changes: 2 additions & 2 deletions packages/docs/src/components/theme-toggle/theme-toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { component$, event$, useContext, useStyles$ } from '@builder.io/qwik';
import { component$, $, useContext, useStyles$ } from '@builder.io/qwik';
import { SunAndMoon } from './sun-and-moon';
import { themeStorageKey } from '../router-head/theme-script';
import themeToggle from './theme-toggle.css?inline';
Expand Down Expand Up @@ -45,7 +45,7 @@ export const ThemeToggle = component$(() => {
useStyles$(themeToggle);
const state = useContext(GlobalStore);

const onClick$ = event$(() => {
const onClick$ = $(() => {
state.theme = state.theme === 'light' ? 'dark' : 'light';
setPreference(state.theme);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/api/qwik/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@
}
],
"kind": "Function",
"content": "```typescript\nevent$: <T>(qrl: T) => QRL<T>\n```\n\n\n<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nqrl\n\n\n</td><td>\n\nT\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\n[QRL](#qrl)<!-- -->&lt;T&gt;",
"content": "> Warning: This API is now obsolete.\n> \n> It will be removed in v2. Instead, use `$()`<!-- -->, and inside the function add `if (isServer) { return; }`\n> \n\n\n```typescript\nevent$: <T>(qrl: T) => QRL<T>\n```\n\n\n<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nqrl\n\n\n</td><td>\n\nT\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\n[QRL](#qrl)<!-- -->&lt;T&gt;",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/qrl/qrl.public.ts",
"mdFile": "qwik.event_.md"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/docs/src/routes/api/qwik/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,10 @@ any \| undefined

## event$

> Warning: This API is now obsolete.
>
> It will be removed in v2. Instead, use `$()`, and inside the function add `if (isServer) { return; }`

```typescript
event$: <T>(qrl: T) => QRL<T>;
```
Expand Down
20 changes: 11 additions & 9 deletions packages/qwik-city/src/middleware/bun/middleware.bun.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import type { ClientConn } from '@builder.io/qwik-city/middleware/request-handler';
import type { ServerRenderOptions } from '@builder.io/qwik-city/middleware/request-handler';

// @public (undocumented)
export function createQwikCity(opts: QwikCityBunOptions): {
router: (request: Request) => Promise<Response | null>;
notFound: (request: Request) => Promise<Response>;
staticFile: (request: Request) => Promise<Response | null>;
router: (request: Request) => Promise<Response | null>;
notFound: (request: Request) => Promise<Response>;
staticFile: (request: Request) => Promise<Response | null>;
};

// @public (undocumented)
export interface QwikCityBunOptions extends ServerRenderOptions {
// (undocumented)
getClientConn?: (request: Request) => ClientConn;
static?: {
root?: string;
cacheControl?: string;
};
// (undocumented)
getClientConn?: (request: Request) => ClientConn;
static?: {
root?: string;
cacheControl?: string;
};
}

// (No @packageDocumentation comment for this package)

```
36 changes: 19 additions & 17 deletions packages/qwik-city/src/middleware/deno/middleware.deno.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,43 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import type { ClientConn } from '@builder.io/qwik-city/middleware/request-handler';
import type { ServerRenderOptions } from '@builder.io/qwik-city/middleware/request-handler';

// @public (undocumented)
export function createQwikCity(opts: QwikCityDenoOptions): {
router: (request: Request, info: ServeHandlerInfo) => Promise<Response | null>;
notFound: (request: Request) => Promise<Response>;
staticFile: (request: Request) => Promise<Response | null>;
router: (request: Request, info: ServeHandlerInfo) => Promise<Response | null>;
notFound: (request: Request) => Promise<Response>;
staticFile: (request: Request) => Promise<Response | null>;
};

// @public (undocumented)
export interface NetAddr {
// (undocumented)
hostname: string;
// (undocumented)
port: number;
// (undocumented)
transport: 'tcp' | 'udp';
// (undocumented)
hostname: string;
// (undocumented)
port: number;
// (undocumented)
transport: 'tcp' | 'udp';
}

// @public (undocumented)
export interface QwikCityDenoOptions extends ServerRenderOptions {
// (undocumented)
getClientConn?: (request: Request, info: ServeHandlerInfo) => ClientConn;
static?: {
root?: string;
cacheControl?: string;
};
// (undocumented)
getClientConn?: (request: Request, info: ServeHandlerInfo) => ClientConn;
static?: {
root?: string;
cacheControl?: string;
};
}

// @public (undocumented)
export interface ServeHandlerInfo {
// (undocumented)
remoteAddr: NetAddr;
// (undocumented)
remoteAddr: NetAddr;
}

// (No @packageDocumentation comment for this package)

```
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// @public @deprecated (undocumented)
export const setupServiceWorker: () => void;

// (No @packageDocumentation comment for this package)

```
11 changes: 8 additions & 3 deletions packages/qwik-city/src/runtime/src/spa-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { ClientSPAWindow } from './qwik-city-component';
import type { ScrollHistoryState } from './scroll-restoration';
import type { ScrollState } from './types';

import { isDev } from '@builder.io/qwik';
import { event$ } from '@builder.io/qwik';
import { isDev, isServer } from '@builder.io/qwik';
import { $ } from '@builder.io/qwik';

// TODO Dedupe handler code from here and QwikCityProvider?
// TODO Navigation API; check for support & simplify.
Expand All @@ -14,13 +14,18 @@ import { event$ } from '@builder.io/qwik';
// - Robust, fully relies only on history. (scrollRestoration = 'manual')

// ! DO NOT IMPORT OR USE ANY EXTERNAL REFERENCES IN THIS SCRIPT.
export default event$((_: Event, el: Element) => {
export default $((_: Event, el: Element) => {
const win: ClientSPAWindow = window;
const spa = '_qCitySPA';
const initPopstate = '_qCityInitPopstate';
const initAnchors = '_qCityInitAnchors';
const initVisibility = '_qCityInitVisibility';
const initScroll = '_qCityInitScroll';

if (isServer) {
return;
}

if (
!win[spa] &&
!win[initPopstate] &&
Expand Down
50 changes: 26 additions & 24 deletions packages/qwik-city/src/static/qwik-city.static.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

/// <reference types="node" />

import type { RenderOptions } from '@builder.io/qwik/server';
Expand All @@ -12,39 +13,40 @@ export function generate(opts: StaticGenerateOptions): Promise<StaticGenerateRes

// @public (undocumented)
export interface StaticGenerateOptions extends StaticGenerateRenderOptions {
basePathname?: string;
qwikCityPlanModulePath: string;
renderModulePath: string;
// (undocumented)
rootDir?: string;
basePathname?: string;
qwikCityPlanModulePath: string;
renderModulePath: string;
// (undocumented)
rootDir?: string;
}

// @public (undocumented)
export interface StaticGenerateRenderOptions extends RenderOptions {
emit404Pages?: boolean;
emitData?: boolean;
emitHtml?: boolean;
exclude?: string[];
include?: string[];
log?: 'debug';
maxTasksPerWorker?: number;
maxWorkers?: number;
origin: string;
outDir: string;
sitemapOutFile?: string | null;
emit404Pages?: boolean;
emitData?: boolean;
emitHtml?: boolean;
exclude?: string[];
include?: string[];
log?: 'debug';
maxTasksPerWorker?: number;
maxWorkers?: number;
origin: string;
outDir: string;
sitemapOutFile?: string | null;
}

// @public (undocumented)
export interface StaticGenerateResult {
// (undocumented)
duration: number;
// (undocumented)
errors: number;
// (undocumented)
rendered: number;
// (undocumented)
staticPaths: string[];
// (undocumented)
duration: number;
// (undocumented)
errors: number;
// (undocumented)
rendered: number;
// (undocumented)
staticPaths: string[];
}

// (No @packageDocumentation comment for this package)

```
2 changes: 2 additions & 0 deletions packages/qwik/src/build/qwik.build.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// @public
export const isBrowser: boolean;

Expand All @@ -13,4 +14,5 @@ export const isDev: boolean;
export const isServer: boolean;

// (No @packageDocumentation comment for this package)

```
2 changes: 1 addition & 1 deletion packages/qwik/src/core/qrl/qrl.public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export const eventQrl = <T>(qrl: QRL<T>): QRL<T> => {
return qrl;
};

/** @public */
/** @public @deprecated It will be removed in v2. Instead, use `$()`, and inside the function add `if (isServer) { return; }` */
export const event$ = implicit$FirstArg(eventQrl);

/** @alpha */
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/qwik.core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export interface ErrorBoundaryStore {
error: any | undefined;
}

// @public (undocumented)
// @public @deprecated (undocumented)
export const event$: <T>(qrl: T) => QRL<T>;

// @public
Expand Down
4 changes: 2 additions & 2 deletions starters/apps/e2e/src/components/render/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
useStore,
useStylesScoped$,
useTask$,
event$,
$,
h,
jsx,
SkipRender,
Expand Down Expand Up @@ -549,7 +549,7 @@ export const Issue3398 = component$(() => {
export const Issue3479 = component$(() => {
const count = useSignal(0);
const attributes = {
onClick$: event$(() => count.value++),
onClick$: $(() => count.value++),
};
const countStr = String(count.value) + "";
return (
Expand Down