@@ -34,7 +34,6 @@ pub enum BenchMsg {
3434}
3535
3636pub struct Benchmarks {
37- link : ComponentLink < Self > ,
3837 finished : bool ,
3938
4039 parse_simple : Option < f64 > ,
@@ -56,9 +55,8 @@ impl Component for Benchmarks {
5655 type Message = BenchMsg ;
5756 type Properties = ( ) ;
5857
59- fn create ( _: Self :: Properties , link : ComponentLink < Self > ) -> Self {
58+ fn create ( _: & Context < Self > ) -> Self {
6059 Self {
61- link,
6260 finished : false ,
6361 parse_simple : None ,
6462 macro_simple : None ,
@@ -74,45 +72,45 @@ impl Component for Benchmarks {
7472 }
7573 }
7674
77- fn rendered ( & mut self , first_render : bool ) {
75+ fn rendered ( & mut self , ctx : & Context < Self > , first_render : bool ) {
7876 if first_render {
79- let cb = self
80- . link
77+ let cb = ctx
78+ . link ( )
8179 . callback ( |_| BenchMsg :: ParseSimpleFinish ( benchmarks:: bench_parse_simple ( ) ) ) ;
8280 Timeout :: new ( 100 , move || cb. emit ( ( ) ) ) . forget ( ) ;
8381 }
8482 }
8583
86- fn update ( & mut self , msg : Self :: Message ) -> ShouldRender {
84+ fn update ( & mut self , ctx : & Context < Self > , msg : Self :: Message ) -> bool {
8785 match msg {
8886 BenchMsg :: ParseSimpleFinish ( m) => {
8987 self . parse_simple = Some ( m) ;
90- let cb = self
91- . link
88+ let cb = ctx
89+ . link ( )
9290 . callback ( |_| BenchMsg :: MacroSimpleFinish ( benchmarks:: bench_macro_simple ( ) ) ) ;
9391
9492 Timeout :: new ( 100 , move || cb. emit ( ( ) ) ) . forget ( ) ;
9593 }
9694 BenchMsg :: MacroSimpleFinish ( m) => {
9795 self . macro_simple = Some ( m) ;
98- let cb = self . link . callback ( |_| {
96+ let cb = ctx . link ( ) . callback ( |_| {
9997 BenchMsg :: MacroInlineSimpleFinish ( benchmarks:: bench_macro_inline_simple ( ) )
10098 } ) ;
10199
102100 Timeout :: new ( 100 , move || cb. emit ( ( ) ) ) . forget ( ) ;
103101 }
104102 BenchMsg :: MacroInlineSimpleFinish ( m) => {
105103 self . macro_inline_simple = Some ( m) ;
106- let cb = self . link . callback ( |_| {
104+ let cb = ctx . link ( ) . callback ( |_| {
107105 BenchMsg :: ParseSimpleNoCacheFinish ( benchmarks:: bench_parse_simple_no_cache ( ) )
108106 } ) ;
109107
110108 Timeout :: new ( 100 , move || cb. emit ( ( ) ) ) . forget ( ) ;
111109 }
112110 BenchMsg :: ParseSimpleNoCacheFinish ( m) => {
113111 self . parse_simple_no_cache = Some ( m) ;
114- let cb = self
115- . link
112+ let cb = ctx
113+ . link ( )
116114 . callback ( |_| BenchMsg :: ParseComplexFinish ( benchmarks:: bench_parse_complex ( ) ) ) ;
117115
118116 Timeout :: new ( 100 , move || cb. emit ( ( ) ) ) . forget ( ) ;
@@ -121,16 +119,16 @@ impl Component for Benchmarks {
121119 BenchMsg :: ParseComplexFinish ( m) => {
122120 self . parse_complex = Some ( m) ;
123121
124- let cb = self
125- . link
122+ let cb = ctx
123+ . link ( )
126124 . callback ( |_| BenchMsg :: MacroComplexFinish ( benchmarks:: bench_macro_complex ( ) ) ) ;
127125
128126 Timeout :: new ( 100 , move || cb. emit ( ( ) ) ) . forget ( ) ;
129127 }
130128 BenchMsg :: MacroComplexFinish ( m) => {
131129 self . macro_complex = Some ( m) ;
132130
133- let cb = self . link . callback ( |_| {
131+ let cb = ctx . link ( ) . callback ( |_| {
134132 BenchMsg :: MacroInlineComplexFinish ( benchmarks:: bench_macro_inline_complex ( ) )
135133 } ) ;
136134
@@ -139,7 +137,7 @@ impl Component for Benchmarks {
139137 BenchMsg :: MacroInlineComplexFinish ( m) => {
140138 self . macro_inline_complex = Some ( m) ;
141139
142- let cb = self . link . callback ( |_| {
140+ let cb = ctx . link ( ) . callback ( |_| {
143141 BenchMsg :: ParseComplexNoCacheFinish ( benchmarks:: bench_parse_complex_no_cache ( ) )
144142 } ) ;
145143
@@ -148,8 +146,8 @@ impl Component for Benchmarks {
148146 BenchMsg :: ParseComplexNoCacheFinish ( m) => {
149147 self . parse_complex_no_cache = Some ( m) ;
150148
151- let cb = self
152- . link
149+ let cb = ctx
150+ . link ( )
153151 . callback ( |_| BenchMsg :: CachedLookupFinish ( benchmarks:: bench_cached_lookup ( ) ) ) ;
154152
155153 Timeout :: new ( 100 , move || cb. emit ( ( ) ) ) . forget ( ) ;
@@ -159,7 +157,7 @@ impl Component for Benchmarks {
159157 self . cached_lookup = Some ( m) ;
160158
161159 let cb =
162- self . link . callback ( |_| {
160+ ctx . link ( ) . callback ( |_| {
163161 BenchMsg :: CachedLookupBigSheetFinish (
164162 benchmarks:: bench_cached_lookup_big_sheet ( ) ,
165163 )
@@ -171,8 +169,8 @@ impl Component for Benchmarks {
171169 BenchMsg :: CachedLookupBigSheetFinish ( m) => {
172170 self . cached_lookup_big_sheet = Some ( m) ;
173171
174- let cb = self
175- . link
172+ let cb = ctx
173+ . link ( )
176174 . callback ( |_| BenchMsg :: MountingFinish ( benchmarks:: bench_mounting ( ) ) ) ;
177175
178176 Timeout :: new ( 100 , move || cb. emit ( ( ) ) ) . forget ( ) ;
@@ -186,13 +184,13 @@ impl Component for Benchmarks {
186184 true
187185 }
188186
189- fn change ( & mut self , _: Self :: Properties ) -> ShouldRender {
187+ fn changed ( & mut self , _: & Context < Self > ) -> bool {
190188 false
191189 }
192190
193- fn view ( & self ) -> Html {
191+ fn view ( & self , _ : & Context < Self > ) -> Html {
194192 html ! {
195- <div class=self . style( ) >
193+ <div class={ self . style( ) } >
196194 {
197195 if !self . finished {
198196 html!{ <div class="running" >{ "Benchmarking..." } <br />{ "The browser may be unresponsive during the benchmark." } </div>}
@@ -316,38 +314,34 @@ pub enum AppMsg {
316314}
317315
318316pub struct App {
319- link : ComponentLink < Self > ,
320317 started : bool ,
321318}
322319
323320impl Component for App {
324321 type Message = AppMsg ;
325322 type Properties = ( ) ;
326323
327- fn create ( _: Self :: Properties , link : ComponentLink < Self > ) -> Self {
328- Self {
329- link,
330- started : false ,
331- }
324+ fn create ( _: & Context < Self > ) -> Self {
325+ Self { started : false }
332326 }
333327
334- fn update ( & mut self , msg : Self :: Message ) -> ShouldRender {
328+ fn update ( & mut self , _ : & Context < Self > , msg : Self :: Message ) -> bool {
335329 assert_eq ! ( msg, AppMsg :: Start ) ;
336330
337331 self . started = true ;
338332
339333 true
340334 }
341335
342- fn change ( & mut self , _: Self :: Properties ) -> ShouldRender {
336+ fn changed ( & mut self , _: & Context < Self > ) -> bool {
343337 false
344338 }
345339
346- fn view ( & self ) -> Html {
340+ fn view ( & self , ctx : & Context < Self > ) -> Html {
347341 html ! {
348342 <>
349- <Global css=GLOBAL_STYLE />
350- <div class=self . style( ) >
343+ <Global css={ GLOBAL_STYLE } />
344+ <div class={ self . style( ) } >
351345 <h1>{ "Stylist Benchmark" } </h1>
352346 {
353347 if self . started {
@@ -356,7 +350,7 @@ impl Component for App {
356350 html!{
357351 <>
358352 <div class="before-intro" >{ "To start benchmarking, please click start:" } </div>
359- <button onclick=self . link. callback( |_| AppMsg :: Start ) >
353+ <button onclick={ ctx . link( ) . callback( |_| AppMsg :: Start ) } >
360354 { "Start!" }
361355 </button>
362356 </>
0 commit comments