Hook Proposal: useTimeoutControlledFn — a manual version of useTimeoutFn
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start by locating the existing useTimeoutFn implementation and its tests, since this proposal defines a manual variant of that hook. Confirm the start, cancel, reset, and readiness behavior from the issue, then add tests and documentation showing that no timeout starts on mount and that the requested API works.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
useTimeoutFn, starts the timeout automatically on mount. In our case, we needed something similar but fully manual which is a timeout only starts when we explicitly trigger it (e.g., after an API success).
Why this might be useful
- No automatic timeout on mount
- Full control:
start(),cancel(),reset() - Ability to reuse the last delay (
reset) - Useful in callbacks, controlled UI flows, etc.
API
const [isReady, cancel, start, reset] = useTimeoutControlledFn(fn, defaultMs?: number);
isReady()→ returnstrue | false | nullcancel()→ cancels the current timeoutstart(delay?)→ starts a new timeoutreset()→ reuses last delay
Example
const [isReady, cancel, start, reset] = useTimeoutControlledFn(() => {
console.log('Executed after delay!');
}, 1500);
// Manually start after a successful API call
const onApiSuccess = () => start();
If this sounds useful, I’m happy to prepare a full PR with tests and docs. Just wanted to get your feedback first
- Ngôn ngữ chính
- TypeScript
- Star
- 44k
- Fork
- 3.3k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của streamich/react-use
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Add Generic Fn for useDebounceCó thể đã có người làm @itsmejay80 đã nhận 189 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
-
useVideo.story.tsx - sampleVideo can not be loadedCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
-
useSlider: event callbacks are not updatedCó thể đã có người làm @erykpiast đã nhận 1836 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Tất cả issue của streamich/react-use
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jbacalso24/mimry#459 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
architecture help wanted hive/claimed-by-architect origin/architect stage/030-pr-in-progress tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kubestellar/console#24422 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: backends type: docs
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 83/100
schlessera/brain-kit#2383 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent duplicate providers tool triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày