v1.2.0
cancelation_token
이 패키지는 취소 토큰 인터페이스 및 다양한 구현(취소 가능, 타임아웃, 복합 등)을 제공합니다.
2좋아요 3.2만30일 다운로드160Pub 점수
AndroidiOSLinuxmacOSWebWindows
취소 토큰 인터페이스 + 몇 가지 구현
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
This package provides an interface for cancelation tokens as well as various implementations:
CancelableToken which can be canceled programmatically;CompositeToken which is canceled when any or all tokens are canceled;TimeoutToken which is canceled after a timeout period.Cancel a long-running execution after a timeout.
import 'package:cancelation_token/cancelation_token.dart';
void main() async {
final timeout = Duration(seconds: 5);
final errorOnTimeout = CanceledException.withStackTrace('Too long!');
final token = TimeoutToken(timeout, errorOnTimeout);
token.ensureStarted();
try {
await longProcess(token);
} on CanceledException catch (ex, st) {
print(ex.message);
print(ex.stackTrace);
print(st);
}
}
Future<void> longProcess(CancelationToken token) async {
// very long indeed!
while (true) {
token.throwIfCanceled();
await Future.delayed(const Duration(milliseconds: 100));
}
}
사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗