Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace swap built-in with reconcile #654

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frameworks/keyed/mikado/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
},
"scripts": {
"compile": "mikado-compile src/template/app.html && mikado-compile src/template/item.html && echo Compile Complete. && exit 0",
"build": "npm run compile && node task/build RELEASE=custom DEBUG=false USE_POLYFILL=false SUPPORT_CACHE=false SUPPORT_EVENTS=true SUPPORT_STORAGE=true SUPPORT_HELPERS='swap' SUPPORT_ASYNC=false SUPPORT_TRANSPORT=false SUPPORT_TEMPLATE_EXTENSION=false SUPPORT_REACTIVE=false SUPPORT_CACHE_HELPERS=false SUPPORT_POOLS=false SUPPORT_COMPILE=false && exit 0",
"build": "npm run compile && node task/build RELEASE=custom DEBUG=false USE_POLYFILL=false SUPPORT_CACHE=false SUPPORT_EVENTS=true SUPPORT_STORAGE=false SUPPORT_HELPERS=false SUPPORT_ASYNC=false SUPPORT_TRANSPORT=false SUPPORT_TEMPLATE_EXTENSION=false SUPPORT_REACTIVE=false SUPPORT_CACHE_HELPERS=false SUPPORT_POOLS=false SUPPORT_CALLBACKS=false SUPPORT_COMPILE=false && exit 0",
"build-prod": "npm run build"
},
"dependencies": {
"mikado": "^0.6.53"
"mikado": "0.7.35"
},
"devDependencies": {
"google-closure-compiler": "20191012.0.0-nightly",
"google-closure-compiler": "20191027.0.0-nightly",
"mikado-compile": "0.6.5"
}
}
16 changes: 8 additions & 8 deletions frameworks/keyed/mikado/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ let _nextId = 1;

export function buildData(count){

if(count === 1){

return {

id: _nextId++,
label: ADJECTIVES[_random(len_ADJECTIVES)] + " " + COLOURS[_random(len_COLOURS)] + " " + NOUNS[_random(len_NOUNS)]
}
}
// if(count === 1){
//
// return {
//
// id: _nextId++,
// label: ADJECTIVES[_random(len_ADJECTIVES)] + " " + COLOURS[_random(len_COLOURS)] + " " + NOUNS[_random(len_NOUNS)]
// }
// }

const data = new Array(count);

Expand Down
18 changes: 12 additions & 6 deletions frameworks/keyed/mikado/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@ import { buildData } from "./data.js";

Mikado.once(document.getElementById("main"), app);

let data;
const state = { "selected": {} };
const root = document.getElementById("tbody");
const mikado = Mikado.new(root, item, {
const mikado = new Mikado(root, item, {
"reuse": false, "state": state
})
.route("run", () => { mikado.render(buildData(1000)) })
.route("runlots", () => { mikado.render(buildData(10000)) })
.route("run", () => { mikado.clear().append(data = buildData(1000)) })
.route("runlots", () => { mikado.clear().append(buildData(10000)) })
.route("add", () => { mikado.append(buildData(1000)) })
.route("update", () => {
for(let i = 0, len = mikado.length; i < len; i += 10){
mikado.data(i).label += " !!!";
mikado.refresh(i);
data[i].label += " !!!";
mikado.apply(mikado.node(i), data[i]);
}
})
.route("clear", () => { mikado.clear() })
.route("swaprows", () => { mikado.swap(1, 998) })
.route("swaprows", () => {
const tmp = data[998]
data[998] = data[1];
data[1] = tmp;
mikado.reconcile(data);
})
.route("remove", target => { mikado.remove(target) })
.route("select", target => {
state["selected"].className = "";
Expand Down
2 changes: 1 addition & 1 deletion frameworks/keyed/mikado/src/template/item.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tr class="{{this.state.selected === self ? 'danger' : ''}}" root>
<tr key="data.id" class="{{this.state.selected === self ? 'danger' : ''}}" root>
<td class="col-md-1">{{data.id}}</td>
<td class="col-md-4">
<a class="lbl" click="select:root">{{data.label}}</a>
Expand Down
4 changes: 2 additions & 2 deletions frameworks/keyed/mikado/task/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const parameter = (function(opt){
generate_exports: true,
export_local_property_definitions: true,
language_in: "ECMASCRIPT6_STRICT",
language_out: "ECMASCRIPT5_STRICT",
language_out: "ECMASCRIPT6_STRICT",
process_closure_primitives: true,
summary_detail_level: 3,
warning_level: "VERBOSE",
Expand Down Expand Up @@ -88,7 +88,7 @@ const parameter = (function(opt){
//formatting: "PRETTY_PRINT"
});

exec("java -jar node_modules/google-closure-compiler-java/compiler.jar" + parameter + " --js='src/*.js' --js='src/template/*.es6.js' --js='node_modules/mikado/src/*.js' --js='!src/*config.js'" + flag_str + " --js_output_file='dist/main.js' && exit 0", function(){
exec("java -jar node_modules/google-closure-compiler-java/compiler.jar" + parameter + " --js='src/*.js' --js='src/template/*.es6.js' --js='node_modules/mikado/src/*.js'" + flag_str + " --js_output_file='dist/main.js' && exit 0", function(){

console.log("Build Complete.");
});
Expand Down