Skip to content
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "qwik-monorepo",
"version": "0.0.36",
"version": "0.0.37",
"scripts": {
"build": "yarn node scripts --tsc --build --qwikcity --api --platform-binding-wasm-copy",
"build.full": "yarn node scripts --tsc --build --api --eslint --qwikcity --qwikreact --platform-binding --wasm",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-qwik",
"version": "0.0.36",
"version": "0.0.37",
"description": "Interactive CLI and API for generating Qwik projects.",
"bin": "create-qwik",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-qwik",
"version": "0.0.36",
"version": "0.0.37",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"main": "index.js",
"author": "Builder Team",
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik",
"version": "0.0.36",
"version": "0.0.37",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"main": "./dist/core.cjs",
"types": "./dist/core.d.ts",
Expand Down
16 changes: 13 additions & 3 deletions packages/qwik/src/core/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,8 @@ export interface Ref<T> {
// @alpha
export const render: (parent: Element | Document, jsxNode: JSXNode<unknown> | FunctionComponent<any>, allowRerender?: boolean) => Promise<void>;

// Warning: (ae-forgotten-export) The symbol "AsyncProps" needs to be exported by the entry point index.d.ts
//
// @alpha (undocumented)
export const Resource: <T>(props: AsyncProps<T>) => JSXNode;
export const Resource: <T>(props: ResourceProps<T>) => JSXNode;

// @alpha (undocumented)
export interface ResourceCtx<T> {
Expand All @@ -402,6 +400,18 @@ export interface ResourcePending<T> {
state: 'pending';
}

// @alpha (undocumented)
export interface ResourceProps<T> {
// (undocumented)
onPending?: () => JSXNode;
// (undocumented)
onRejected?: (reason: any) => JSXNode;
// (undocumented)
onResolved: (value: T) => JSXNode;
// (undocumented)
resource: ResourceReturn<T>;
}

// @alpha (undocumented)
export interface ResourceRejected<T> {
// (undocumented)
Expand Down
1 change: 1 addition & 0 deletions packages/qwik/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type {
ResourceResolved,
} from './use/use-watch';
export { useWatch$, useWatchQrl } from './use/use-watch';
export type { ResourceProps } from './use/use-resource';
export { useResource$, useResourceQrl, Resource } from './use/use-resource';
export { useClientEffect$, useClientEffectQrl } from './use/use-watch';
export { useServerMount$, useServerMountQrl } from './use/use-watch';
Expand Down
6 changes: 3 additions & 3 deletions packages/qwik/src/core/use/use-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const useIsServer = () => {
/**
* @alpha
*/
export interface AsyncProps<T> {
export interface ResourceProps<T> {
resource: ResourceReturn<T>;
onResolved: (value: T) => JSXNode;
onPending?: () => JSXNode;
Expand All @@ -79,7 +79,7 @@ export interface AsyncProps<T> {
/**
* @alpha
*/
export const Resource = <T>(props: AsyncProps<T>): JSXNode => {
export const Resource = <T>(props: ResourceProps<T>): JSXNode => {
const isBrowser = !qDev || !useIsServer();
if (isBrowser) {
if (props.onRejected) {
Expand All @@ -98,7 +98,7 @@ export const Resource = <T>(props: AsyncProps<T>): JSXNode => {
}
}

// Async path
// Resource path
return jsx(Fragment, {
children: props.resource.promise.then(props.onResolved, props.onRejected),
});
Expand Down