-
-
Save ZoolWay/4caf35a8abc1cedfc8487df1ea997548 to your computer and use it in GitHub Desktop.
Aurelia TaskQueue for DOM rework
This file contains hidden or 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
<template> | |
<h1>${message}</h1> | |
<ul> | |
<li class="entry" repeat.for="item of list">item: ${item}</li> | |
</ul> | |
<div> | |
<button click.trigger="addItem()">Add Bad</button> | |
<button click.trigger="addItemQueued()">Add Queued</button> | |
<button click.trigger="clearLength()">Clear Length</button> | |
<button click.trigger="clearSplice()">Clear Splice</button> | |
<button click.trigger="clearReplace()">Clear Replace</button> | |
</div> | |
</template> |
This file contains hidden or 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
import { inject, TaskQueue } from 'aurelia-framework'; | |
@inject(TaskQueue) | |
export class App { | |
message = 'Hello World!'; | |
list = undefined; | |
taskQueue = undefined; | |
constructor(taskQueue) { | |
this.list = new Array(); | |
this.list.push("itm1"); | |
this.taskQueue = taskQueue; | |
} | |
addItem() { | |
this.list.push("new-item"); | |
this.list.push("new-item"); | |
this.list.push("new-item"); | |
$(".entry").css("border", "2px solid red"); | |
} | |
addItemQueued() { | |
this.list.push("new-item, reworking queued"); | |
this.list.push("new-item, reworking queued"); | |
this.list.push("new-item, reworking queued"); | |
this.list.push("new-item, reworking queued"); | |
this.taskQueue.queueMicroTask(() => { | |
$(".entry").css("border", "2px solid green"); | |
}); | |
} | |
clearLength() { | |
this.list.length = 0; | |
} | |
clearSplice() { | |
this.list.splice(0); | |
} | |
clearReplace() { | |
this.list = []; | |
} | |
} |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> | |
<script> | |
require(['aurelia-bootstrapper']); | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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
Show hidden characters
{ | |
"version": "1.8.10", | |
"compilerOptions": { | |
"rootDir": "./", | |
"sourceMap": true, | |
"target": "es6", | |
"module": "amd", | |
"declaration": false, | |
"noImplicitAny": false, | |
"noResolve": true, | |
"removeComments": true, | |
"noLib": false, | |
"emitDecoratorMetadata": true, | |
"experimentalDecorators": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment