सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
async_queue पैकेज एक क्रम में एक-दूसरे के बाद एक श्रृंखला असिंक्रोनस कार्यों को निष्पादित करने की गारंटी देता है, क्रम और समानांतरता समस्याओं को रोकता है। यह नियंत्रित तरीके से असिंक्रोनस ऑपरेशन को संभालने के लिए एक सरल कतार तंत्र प्रदान करता है, जो कार्य के निर्भरता या निष्पादन क्रम महत्वपूर्ण होने पर आदर्श है। Dart के साथ बनाया गया, यह सभी प्रमुख प्लेटफॉर्मों पर Flutter प्रोजेक्ट में बिना किसी दिक्कत के एकीकृत होता है। पैकेज हल्का है और विश्वसनीयता पर ध्यान केंद्रित है, जिससे यह बैकग्राउंड प्रोसेसिंग, API कॉल सीक्वेंसिंग, या किसी भी ऐसे उपयोग केस के लिए उपयुक्त है जिसमें क्रमबद्ध असिंक्रोनस निष्पादन की आवश्यकता होती है।
उपयोग
क्रमिक API कॉल
बैकग्राउंड टास्क प्रोसेसिंग
क्रम-निर्भर संचालन
एसिंक क्रियाकलाप के साथ अवस्था प्रबंधन
क्रम से संसाधन लोड करें
मुख्य विशेषताएँ
क्रमिक निष्पादन की गारंटी
सरल भंडारण इंटरफ़ेस
क्रॉस-प्लेटफ़ॉर्म समर्थन
हल्का और न्यूनतम निर्भरता
थ्रेड-सुरक्षित संचालन
इनके लिए उपयुक्त
क्रमबद्ध एसिंक निष्पादन की आवश्यकता वाले विकासकर्ता
निर्भर एसिंक वर्कफ्लो वाले ऐप्स
पूर्वानुमानित कार्य योजना की आवश्यकता वाले प्रोजेक्ट
बहुप्लेटफॉर्म लक्षित फ्लटर एप्प्स
कोड सरलता को नियमित प्राथमिकता देने वाली टीमें
विचार योग्य बातें
समानांतर कार्य निष्पादन के लिए नहीं
प्रत्येक उदाहरण के लिए एकल भीड़ सीमित
कतार जीवनचक्र के सावधानीपूर्वक प्रबंधन की आवश्यकता होती है
छोटे से मध्यम तक के कार्य बैच के लिए सबसे उपयुक्त
पुनर्प्रयास तर्क या त्रुटि पुनर्स्थापन को संभालता नहीं है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Async Queue - ensure your list of async tasks execute in order
This dart package ensures your pack of async tasks executes in order, one after the other.
What's new in v3.0.0
addJob returns a Future — await individual job results directly, no more listener workarounds
Automatic retry on exceptions — jobs that throw are retried up to retryTime without manual retry() calls
onError callback — handle errors at the queue level: AsyncQueue(onError: (error, label) { ... })
Priority queue — addJob(..., priority: 10) to run important jobs first
final asyncQ = AsyncQueue();
asyncQ.addQueueListener((event) => print("$event"));
Await job result (v3.0.0+)
addJob returns a Future that completes with the job's return value. This works alongside previousResult — they serve different purposes.
final q = AsyncQueue.autoStart();
// Each addJob returns a Future you can await for its resultfinal userFuture = q.addJob((_) async {
returnawait api.getUser(); // returns "Sam"
});
// previousResult still chains between jobsfinal postsFuture = q.addJob((previousResult) async {
returnawait api.getPostsFor(previousResult);
});
final user = await userFuture; // "Sam"final posts = await postsFuture; // [Post, Post, ...]
Automatic retry on exceptions (v3.0.0+)
Jobs that throw are automatically retried up to retryTime times. You no longer need to catch errors and call retry() manually (though you still can for custom logic).
q.addJob((_) async {
// if this throws, it will be retried automaticallyreturnawait api.fetchData();
}, retryTime: 3);
onError callback (v3.0.0+)
Handle errors at the queue level without parsing events:
This package would be useful if you have multiple widgets in a screen or even in multiple screens that need to do some async requests that are related to each other.
For examples:
To make one request from a widget wait for another request from another widget to finish.
To avoid multiple requests from the front end hitting the backend in a short time, which would confuse the backend.