Use Ember Concurrency for User Input Concurrency
এই দিনের কাজ · মোট ১০′০/১ (০%)
- Use Ember Concurrency for User Input Concurrency — নিচের Incorrect কোড পড়ে, না দেখে ঠিক সংস্করণটা লিখুন; তারপর "কেন" ইংরেজিতে ২–৩ বাক্যে জোরে বলুন, আর খাতায় এক লাইন: নিজের কাজে এটা কোথায় দেখেছেন
Incorrect (manual async handling with race conditions):
// app/components/search.gjs import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; class Search extends Component { @tracked results = []; @tracked isSearching = false; @tracked error = null; currentRequest = null; @action async search(event) { const query = event.target.value; // Manual cancelation - easy to get wrong if (this.currentRequest) { this.currentRequest.abort(); } this.isSearching = true; this.error = null; const controller = new AbortController(); this.currentRequest = controller; try { const response = await fetch(`/api/search?q=${query}`, { signal: controller.signal, }); this.results = await response.json(); } catch (e) { if (e.name !== 'AbortError') { this.error = e.message; } } finally { this.isSearching = false; } } <template> <input {{on "input" this.search}} /> {{#if this.isSearching}}Loading...{{/if}} {{#if this.error}}Error: {{this.error}}{{/if}} </template> }১০′🔁 ঝালাই হবেimpact · HIGHCorrect: আগে নিজে লিখুন
দিন শেষে — নিজেকে যাচাই
না দেখে ঠিকটা লেখা, আর "কেন" ইংরেজিতে জোরে বলা হয়েছে?
উত্তরের আগে উপরের কাজ না দেখে মনে করুন এই দিনে কী কী করেছেন। 🧠 Test yourself