-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhaoyongqiang
committed
Feb 29, 2024
1 parent
01f67ad
commit 57eb974
Showing
11 changed files
with
21,954 additions
and
26,902 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { A } from '@ember/array'; | ||
import { run, schedule } from '@ember/runloop'; | ||
import { action } from '@ember/object'; | ||
|
||
interface TaskListSignature { | ||
// The arguments accepted by the component | ||
Args: {}; | ||
// Any blocks yielded by the component | ||
Blocks: { | ||
default: []; | ||
}; | ||
// The element to which `...attributes` is applied in the component template | ||
Element: null; | ||
} | ||
|
||
export default class TaskListComponent extends Component<TaskListSignature> { | ||
@tracked model: number[] = []; | ||
|
||
constructor() { | ||
super(...arguments); | ||
// this.model used in component TaskListComponent, but it had already been used previously in the same computation | ||
// 如果这调用 | ||
// this.loadTask(); | ||
} | ||
|
||
@action | ||
reloadTask() { | ||
console.log('reload task fire'); | ||
this.loadTask(); | ||
// schedule('afterRender', () => { | ||
// this.loadTask(); | ||
// }); | ||
} | ||
|
||
@action | ||
loadTask() { | ||
console.log('load task fire'); | ||
const task = []; | ||
console.log(this.model); | ||
for (let index = 0; index < 10; index++) { | ||
const num = index * Math.random() * 10; | ||
task.push(num); | ||
} | ||
this.model = [...task]; | ||
} | ||
|
||
willDestroy(): void { | ||
super.willDestroy(...arguments); | ||
console.log('willdestroy'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div {{did-update this.reloadTask @tag}} ></div> | ||
<div {{did-insert this.loadTask}}> | ||
{{#each this.model as |item|}} | ||
<div>{{item}}</div> | ||
{{/each}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
export default class TaskController extends Controller { | ||
queryParams = ['tag']; | ||
tag = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default class TaskRoute extends Route { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<ul> | ||
<li> | ||
<LinkTo @route="task" @query={{hash tag="tag1"}}>tag1</LinkTo> | ||
</li> | ||
<li> | ||
<LinkTo @route="task" @query={{hash tag="tag2"}}>tag2</LinkTo> | ||
</li> | ||
</ul> | ||
|
||
<span>{{this.tag}}</span> | ||
|
||
{{!-- {{component "task-list" tag=this.tag}} --}} | ||
|
||
<TaskList @tag={{this.tag}} /> |
Oops, something went wrong.