Skip to content

Commit a1d256b

Browse files
committed
Merge branch 'mmichlin66-master'
2 parents ef71ea6 + a8ff253 commit a1d256b

File tree

10 files changed

+194
-290
lines changed

10 files changed

+194
-290
lines changed

frameworks/keyed/mimbl/build.bat

Lines changed: 0 additions & 8 deletions
This file was deleted.

frameworks/keyed/mimbl/package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/keyed/mimbl/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-framework-benchmark-keyed-mimbl",
3-
"version": "0.6.5",
3+
"version": "0.8.1",
44
"description": "Benchmark for Mimbl framework (keyed)",
55
"js-framework-benchmark": {
66
"frameworkVersionFromPackage": "mimbl"
@@ -27,6 +27,6 @@
2727
"webpack-cli": "^4.6.0"
2828
},
2929
"dependencies": {
30-
"mimbl": "^0.6.5"
30+
"mimbl": "^0.8.1"
3131
}
3232
}

frameworks/keyed/mimbl/src/Main.tsx

Lines changed: 59 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,40 @@ let adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "h
66
let colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
77
let nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"];
88

9-
function _random( max: number)
10-
{
11-
return Math.round(Math.random() * 1000) % max;
9+
type Row = {
10+
id: number;
11+
label: string;
12+
labelTrigger: mim.ITrigger<string>;
13+
selectedTrigger: mim.ITrigger<string>;
1214
}
1315

16+
17+
1418
let nextID = 1;
1519

16-
function buildRows( main: Main, count: number): Row[]
20+
function buildRows( /*main: Main,*/ count: number): Row[]
1721
{
1822
let rows = new Array<Row>( count);
23+
let label: string;
1924
for( let i = 0; i < count; i++)
20-
rows[i] = new Row( main, nextID++,
21-
`${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`);
25+
{
26+
label = `${adjectives[rand(adjectives.length)]} ${colours[rand(colours.length)]} ${nouns[rand(nouns.length)]}`;
27+
rows[i] = {
28+
id: nextID++,
29+
label,
30+
labelTrigger: mim.createTrigger( label),
31+
selectedTrigger: mim.createTrigger()
32+
};
33+
}
2234

2335
return rows;
2436
}
2537

38+
function rand( max: number)
39+
{
40+
return Math.round(Math.random() * 1000) % max;
41+
}
42+
2643

2744

2845
function Button( props: mim.IHtmlButtonElementProps, children: any[]): any
@@ -36,9 +53,9 @@ function Button( props: mim.IHtmlButtonElementProps, children: any[]): any
3653

3754
class Main extends mim.Component
3855
{
39-
private rows: Row[] = null;
56+
@mim.trigger(0) private rows: Row[] = null;
4057
public selectedRow: Row = undefined;
41-
private vnTBody: mim.IElmVN<HTMLElement>;
58+
@mim.ref private vnTBody: mim.IElmVN<HTMLElement>;
4259

4360
public render()
4461
{
@@ -61,49 +78,66 @@ class Main extends mim.Component
6178
</div>
6279
</div>
6380
<table class="table table-hover table-striped test-data">
64-
<tbody vnref={(r) => this.vnTBody = r} updateStrategy={{disableKeyedNodeRecycling: true}}>
65-
{this.rows}
66-
</tbody>
81+
{this.renderRows}
6782
</table>
6883
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
6984
</div>);
7085
}
7186

87+
private renderRows(): any
88+
{
89+
return <tbody vnref={this.vnTBody} updateStrategy={{disableKeyedNodeRecycling: true}}>
90+
{this.rows?.map( row =>
91+
<tr class={row.selectedTrigger} key={row}>
92+
<td class="col-md-1">{row.id}</td>
93+
<td class="col-md-4"><a click={[this.onSelectRowClicked, row]}>{row.labelTrigger}</a></td>
94+
<td class="col-md-1">
95+
<a click={[this.onDeleteRowClicked, row]}>
96+
<span class="glyphicon glyphicon-remove" aria-hidden="true"/>
97+
</a>
98+
</td>
99+
<td class="col-md-6"/>
100+
</tr>
101+
)}
102+
</tbody>
103+
}
104+
72105
private onCreate1000()
73106
{
74-
this.rows = buildRows( this, 1000);
107+
this.rows = buildRows( 1000);
75108
this.selectedRow = undefined;
76-
this.vnTBody.setChildren( this.rows);
77109
}
78110

79111
private onAppend1000()
80112
{
81-
let newRows = buildRows( this, 1000);
113+
let newRows = buildRows( 1000);
82114
this.rows = this.rows ? this.rows.concat( newRows) : newRows;
83-
this.vnTBody.growChildren( undefined, newRows);
84115
}
85116

86117
private onUpdateEvery10th()
87118
{
88119
if (!this.rows)
89120
return;
90121

122+
let row: Row;
91123
for (let i = 0; i < this.rows.length; i += 10)
92-
this.rows[i].updateLabel()
124+
{
125+
row = this.rows[i];
126+
row.labelTrigger.set( row.label += " !!!")
127+
}
93128
}
94129

130+
95131
private onCreate10000()
96132
{
97-
this.rows = buildRows( this, 10000);
133+
this.rows = buildRows( 10000);
98134
this.selectedRow = undefined;
99-
this.vnTBody.setChildren( this.rows);
100135
}
101136

102137
private onClear()
103138
{
104139
this.rows = null;
105140
this.selectedRow = undefined;
106-
this.vnTBody.setChildren( null);
107141
}
108142

109143
private onSwapRows()
@@ -117,84 +151,29 @@ class Main extends mim.Component
117151
}
118152
}
119153

120-
public onSelectRowClicked( rowToSelect: Row)
154+
public onSelectRowClicked = (e: MouseEvent, rowToSelect: Row): void =>
121155
{
122156
if (rowToSelect === this.selectedRow)
123157
return;
124158

125159
if (this.selectedRow)
126-
this.selectedRow.trVN.setProps( {class: undefined});
160+
this.selectedRow.selectedTrigger.set( null);
127161

128162
this.selectedRow = rowToSelect;
129-
this.selectedRow.trVN.setProps( {class: "danger"});
163+
rowToSelect.selectedTrigger.set( "danger");
130164
}
131165

132-
public onDeleteRowClicked( rowToDelete: Row)
166+
public onDeleteRowClicked = (e: MouseEvent, rowToDelete: Row): void =>
133167
{
134168
if (rowToDelete === this.selectedRow)
135169
this.selectedRow = undefined;
136170

137-
let id = rowToDelete.id;
138-
let i = this.rows.findIndex( row => row.id == id);
171+
let i = this.rows.indexOf( rowToDelete);
139172
this.rows.splice( i, 1);
140-
this.vnTBody.spliceChildren( i, 1);
173+
this.vnTBody.spliceChildren( i, 1, undefined, mim.TickSchedulingType.Sync);
141174
}
142175
}
143176

144-
let glyphVN = <span class="glyphicon glyphicon-remove" aria-hidden="true"/>;
145-
let lastCellVN = <td class="col-md-6"/>;
146-
147-
class Row extends mim.Component
148-
{
149-
main: Main;
150-
id: number;
151-
// label: string;
152-
labelVN: mim.ITextVN;
153-
trVN: mim.IElmVN<HTMLTableRowElement>;
154-
155-
constructor( main: Main, id: number, label: string)
156-
{
157-
super();
158-
159-
this.main = main;
160-
this.id = id;
161-
// this.label = label;
162-
this.labelVN = mim.createTextVN( label);
163-
}
164-
165-
public willMount()
166-
{
167-
this.trVN = <tr>
168-
<td class="col-md-1">{this.id}</td>
169-
<td class="col-md-4"><a click={this.onSelectClicked}>{this.labelVN}</a></td>
170-
<td class="col-md-1"><a click={this.onDeleteClicked}>{glyphVN}</a></td>
171-
{lastCellVN}
172-
</tr> as mim.IElmVN<HTMLTableRowElement>;
173-
}
174-
175-
@mim.noWatcher
176-
public render()
177-
{
178-
return this.trVN;
179-
}
180-
181-
public updateLabel()
182-
{
183-
// this.labelVN.setText( this.label += " !!!");
184-
this.labelVN.setText( this.labelVN.text + " !!!");
185-
}
186-
187-
private onDeleteClicked()
188-
{
189-
this.main.onDeleteRowClicked( this);
190-
}
191-
192-
private onSelectClicked()
193-
{
194-
this.main.onSelectRowClicked( this);
195-
}
196-
}
197-
198177

199178

200179
mim.mount( <Main/>, document.getElementById('main'));

frameworks/keyed/solid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
"rollup": "2.52.3",
2828
"rollup-plugin-terser": "7.0.2"
2929
}
30-
}
30+
}

frameworks/non-keyed/mimbl/build.bat

Lines changed: 0 additions & 8 deletions
This file was deleted.

frameworks/non-keyed/mimbl/package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/non-keyed/mimbl/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-framework-benchmark-non-keyed-mimbl",
3-
"version": "0.6.5",
3+
"version": "0.8.1",
44
"description": "Benchmark for Mimbl framework (non-keyed)",
55
"js-framework-benchmark": {
66
"frameworkVersionFromPackage": "mimbl"
@@ -27,6 +27,6 @@
2727
"webpack-cli": "^4.6.0"
2828
},
2929
"dependencies": {
30-
"mimbl": "^0.6.5"
30+
"mimbl": "^0.8.1"
3131
}
3232
}

0 commit comments

Comments
 (0)