Use Reactive Collections from @ember/reactive/collections
এই দিনের কাজ · মোট ১০′০/১ (০%)
- Use Reactive Collections from @ember/reactive/collections — নিচের Incorrect কোড পড়ে, না দেখে ঠিক সংস্করণটা লিখুন; তারপর "কেন" ইংরেজিতে ২–৩ বাক্যে জোরে বলুন, আর খাতায় এক লাইন: নিজের কাজে এটা কোথায় দেখেছেন
Incorrect (non-reactive array):
// app/components/todo-list.gjs import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; export default class TodoList extends Component { @tracked todos = []; // ❌ Array mutations (push, splice, etc.) won't trigger updates @action addTodo(text) { // This won't trigger a re-render! this.todos.push({ id: Date.now(), text }); } @action removeTodo(id) { // This also won't trigger a re-render! const index = this.todos.findIndex((t) => t.id === id); this.todos.splice(index, 1); } <template> <ul> {{#each this.todos as |todo|}} <li> {{todo.text}} <button {{on "click" (fn this.removeTodo todo.id)}}>Remove</button> </li> {{/each}} </ul> <button {{on "click" (fn this.addTodo "New todo")}}>Add</button> </template> }১০′🔁 ঝালাই হবেimpact · HIGHCorrect: আগে নিজে লিখুন
দিন শেষে — নিজেকে যাচাই
না দেখে ঠিকটা লেখা, আর "কেন" ইংরেজিতে জোরে বলা হয়েছে?
উত্তরের আগে উপরের কাজ না দেখে মনে করুন এই দিনে কী কী করেছেন। 🧠 Test yourself