rask-ui 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/createTask.d.ts +9 -8
- package/dist/createTask.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -730,7 +730,7 @@ function Child() {
|
|
|
730
730
|
|
|
731
731
|
A low-level reactive primitive for managing any async operation. `createTask` provides the foundation for building data fetching, mutations, polling, debouncing, and any other async pattern you need. It gives you full control without prescribing specific patterns.
|
|
732
732
|
|
|
733
|
-
The `Task<
|
|
733
|
+
The `Task<P, T>` type is also exported for type annotations. When used with one type parameter, it represents a task with no parameters. With two type parameters, the first is the params type and the second is the return type.
|
|
734
734
|
|
|
735
735
|
```tsx
|
|
736
736
|
import { createTask, createState } from "rask-ui";
|
|
@@ -868,13 +868,13 @@ function TodoList() {
|
|
|
868
868
|
|
|
869
869
|
```tsx
|
|
870
870
|
// Task without parameters - auto-runs on creation
|
|
871
|
-
createTask<T>(task: () => Promise<T>): Task<T
|
|
871
|
+
createTask<T>(task: () => Promise<T>): Task<T> & {
|
|
872
872
|
run(): Promise<T>;
|
|
873
873
|
rerun(): Promise<T>;
|
|
874
874
|
}
|
|
875
875
|
|
|
876
876
|
// Task with parameters - manual control
|
|
877
|
-
createTask<P, T>(task: (params: P) => Promise<T>): Task<
|
|
877
|
+
createTask<P, T>(task: (params: P) => Promise<T>): Task<P, T> & {
|
|
878
878
|
run(params: P): Promise<T>;
|
|
879
879
|
rerun(params: P): Promise<T>;
|
|
880
880
|
}
|
|
@@ -890,8 +890,11 @@ import { Task } from "rask-ui";
|
|
|
890
890
|
// Task that returns a string, no parameters
|
|
891
891
|
const myTask: Task<string>;
|
|
892
892
|
|
|
893
|
-
// Task that
|
|
894
|
-
const myTask: Task<
|
|
893
|
+
// Task that accepts string parameters and returns a string
|
|
894
|
+
const myTask: Task<string, string>;
|
|
895
|
+
|
|
896
|
+
// Task that accepts a number parameter and returns a User object
|
|
897
|
+
const myTask: Task<number, User>;
|
|
895
898
|
```
|
|
896
899
|
|
|
897
900
|
**Returns:** Task object with reactive state and methods:
|
package/dist/createTask.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type TaskState<P, T> = {
|
|
2
2
|
isRunning: false;
|
|
3
3
|
params: null;
|
|
4
4
|
result: null;
|
|
@@ -19,12 +19,13 @@ export type Task<P, T> = {
|
|
|
19
19
|
result: null;
|
|
20
20
|
error: string;
|
|
21
21
|
};
|
|
22
|
-
export
|
|
23
|
-
run(): Promise<
|
|
24
|
-
rerun(): Promise<
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
rerun(params: P): Promise<T>;
|
|
22
|
+
export type Task<A, B = never> = [B] extends [never] ? TaskState<null, A> & {
|
|
23
|
+
run(): Promise<A>;
|
|
24
|
+
rerun(): Promise<A>;
|
|
25
|
+
} : TaskState<A, B> & {
|
|
26
|
+
run(params: A): Promise<B>;
|
|
27
|
+
rerun(params: A): Promise<B>;
|
|
29
28
|
};
|
|
29
|
+
export declare function createTask<T>(task: () => Promise<T>): Task<T>;
|
|
30
|
+
export declare function createTask<P, T>(task: (params: P) => Promise<T>): Task<P, T>;
|
|
30
31
|
//# sourceMappingURL=createTask.d.ts.map
|
package/dist/createTask.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTask.d.ts","sourceRoot":"","sources":["../src/createTask.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"createTask.d.ts","sourceRoot":"","sources":["../src/createTask.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,IACtB;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,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,7 @@ export { render } from "./render";
|
|
|
2
2
|
export { createCleanup, createMountEffect, RaskStatefulComponent, RaskStatelessComponent, } from "./component";
|
|
3
3
|
export { createContext } from "./createContext";
|
|
4
4
|
export { createState, assignState } from "./createState";
|
|
5
|
-
export { createTask, Task } from "./createTask";
|
|
5
|
+
export { createTask, TaskState as Task } from "./createTask";
|
|
6
6
|
export { ErrorBoundary } from "./error";
|
|
7
7
|
export { createRef } from "inferno";
|
|
8
8
|
export { createView } from "./createView";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,SAAS,IAAI,IAAI,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,cAAc,EACd,SAAS,GACV,MAAM,SAAS,CAAC"}
|