@computekit/react 0.1.1 → 0.1.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 +18 -0
- package/dist/index.cjs +624 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +347 -2
- package/dist/index.d.ts +347 -2
- package/dist/index.js +623 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +1198 -2
package/README.md
CHANGED
|
@@ -107,6 +107,7 @@ const {
|
|
|
107
107
|
loading, // Boolean loading state
|
|
108
108
|
error, // Error object if failed
|
|
109
109
|
progress, // Progress info for long tasks
|
|
110
|
+
status, // 'idle' | 'running' | 'success' | 'error' | 'cancelled'
|
|
110
111
|
run, // Function to execute
|
|
111
112
|
reset, // Reset state
|
|
112
113
|
cancel, // Cancel ongoing computation
|
|
@@ -117,8 +118,25 @@ await run(50);
|
|
|
117
118
|
|
|
118
119
|
// With options
|
|
119
120
|
await run(50, { timeout: 5000 });
|
|
121
|
+
|
|
122
|
+
// React to status changes
|
|
123
|
+
if (status === 'success') {
|
|
124
|
+
console.log('Completed!', data);
|
|
125
|
+
} else if (status === 'error') {
|
|
126
|
+
console.error('Failed:', error);
|
|
127
|
+
}
|
|
120
128
|
```
|
|
121
129
|
|
|
130
|
+
**Status values:**
|
|
131
|
+
|
|
132
|
+
| Status | Description |
|
|
133
|
+
| ----------- | ----------------------------------- |
|
|
134
|
+
| `idle` | Initial state, no computation yet |
|
|
135
|
+
| `running` | Computation in progress |
|
|
136
|
+
| `success` | Completed successfully |
|
|
137
|
+
| `error` | Failed with an error |
|
|
138
|
+
| `cancelled` | Cancelled via `cancel()` or unmount |
|
|
139
|
+
|
|
122
140
|
**Options:**
|
|
123
141
|
|
|
124
142
|
| Option | Type | Description |
|