File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ documentation = "https://docs.rs/relm/"
66license = " MIT"
77name = " relm"
88repository = " https://github.com/antoyo/relm"
9- version = " 0.6.0 "
9+ version = " 0.6.1 "
1010
1111[dependencies ]
1212cairo-rs = " ^0.1.2"
Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ impl Widget for Label {
5151 }
5252 }
5353
54+ fn init_view ( & self ) {
55+ self . label . set_text ( "Test" ) ;
56+ }
57+
5458 fn update ( & mut self , _event : LabelMsg , _model : & mut LabelModel ) {
5559 self . label . set_text ( "" ) ;
5660 }
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ documentation = "https://docs.rs/relm-gen-widget/"
55license = " MIT"
66name = " relm-gen-widget"
77repository = " https://github.com/antoyo/relm"
8- version = " 0.6.2 "
8+ version = " 0.6.3 "
99
1010[dependencies ]
1111lazy_static = " ^0.2.4"
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ pub fn gen_widget(input: Tokens) -> Tokens {
108108 state. widget_model_type = Some ( get_return_type ( sig) ) ;
109109 new_items. push ( i) ;
110110 } ,
111- "subscriptions" | "update_command" => new_items. push ( i) ,
111+ "init_view" | " subscriptions" | "update_command" => new_items. push ( i) ,
112112 "update" => {
113113 state. widget_msg_type = Some ( get_second_param_type ( & sig) ) ;
114114 state. update_method = Some ( i)
Original file line number Diff line number Diff line change @@ -391,6 +391,7 @@ fn create_widget_test<WIDGET>(remote: &Remote) -> Component<WIDGET>
391391 let model = WIDGET :: model ( ) ;
392392 ( WIDGET :: view ( relm, & model) , model)
393393 } ;
394+ widget. init_view ( ) ;
394395
395396 let model = Arc :: new ( Mutex :: new ( model) ) ;
396397
@@ -430,6 +431,7 @@ fn create_widget<WIDGET>(remote: &Remote) -> Component<WIDGET>
430431 let model = WIDGET :: model ( ) ;
431432 ( WIDGET :: view ( relm, & model) , model)
432433 } ;
434+ widget. init_view ( ) ;
433435
434436 let model = Arc :: new ( Mutex :: new ( model) ) ;
435437
Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ pub trait Widget
3939 /// Get the containing widget, i.e. the parent widget of the view.
4040 fn container ( & self ) -> & Self :: Container ;
4141
42+ /// Update the view after it is initially created.
43+ /// This method is only useful when using the `#[widget]` attribute, because when not using it,
44+ /// you can use the [`view()`](trait.Widget.html#tymethod.view) method instead.
45+ fn init_view ( & self ) {
46+ }
47+
4248 /// Create the initial model.
4349 fn model ( ) -> Self :: Model ;
4450
You can’t perform that action at this time.
0 commit comments