Skip to content

Commit 26e3513

Browse files
committed
Add stream Lock to avoid emitting events when needed
1 parent 6d130a9 commit 26e3513

25 files changed

+104
-58
lines changed

examples/buttons.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Widget for Win {
6969
// Specify the type of the root widget.
7070
type Root = Window;
7171

72-
fn model(_: ()) -> Model {
72+
fn model(_: &Relm<Self>, _: ()) -> Model {
7373
Model {
7474
counter: 0,
7575
}

examples/child-prop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Widget for Button {
6060
type Msg = ButtonMsg;
6161
type Root = gtk::Button;
6262

63-
fn model(_: ()) -> () {
63+
fn model(_: &Relm<Self>, _: ()) -> () {
6464
}
6565

6666
fn root(&self) -> Self::Root {
@@ -107,7 +107,7 @@ impl Widget for Win {
107107
type Msg = Msg;
108108
type Root = gtk::Window;
109109

110-
fn model(_: ()) -> () {
110+
fn model(_: &Relm<Self>, _: ()) -> () {
111111
}
112112

113113
fn root(&self) -> Self::Root {

examples/clock-nightly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Widget for Win {
5757
type Msg = Msg;
5858
type Root = Window;
5959

60-
fn model(_: ()) -> () {
60+
fn model(_: &Relm<Self>, _: ()) -> () {
6161
()
6262
}
6363

examples/clock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Widget for Win {
5555
type Msg = Msg;
5656
type Root = Window;
5757

58-
fn model(_: ()) -> () {
58+
fn model(_: &Relm<Self>, _: ()) -> () {
5959
()
6060
}
6161

examples/communication-attribute.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ impl Widget for Win {
183183
}
184184

185185
impl Win {
186-
fn inc(&self) -> Option<CounterMsg> {
186+
fn inc(&mut self) -> Option<CounterMsg> {
187187
Some(Increment)
188188
}
189189

190-
fn text_change(&self, input: String) -> Msg {
190+
fn text_change(&mut self, input: String) -> Msg {
191191
TextChange(input)
192192
}
193193
}

examples/communication.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Widget for Text {
6969
type Msg = TextMsg;
7070
type Root = gtk::Box;
7171

72-
fn model(_: ()) -> TextModel {
72+
fn model(_: &Relm<Self>, _: ()) -> TextModel {
7373
TextModel {
7474
content: String::new(),
7575
}
@@ -130,7 +130,7 @@ impl Widget for Counter {
130130
type Msg = CounterMsg;
131131
type Root = gtk::Box;
132132

133-
fn model(_: ()) -> CounterModel {
133+
fn model(_: &Relm<Self>, _: ()) -> CounterModel {
134134
CounterModel {
135135
counter: 0,
136136
}
@@ -203,7 +203,7 @@ impl Widget for Win {
203203
type Msg = Msg;
204204
type Root = Window;
205205

206-
fn model(_: ()) -> Model {
206+
fn model(_: &Relm<Self>, _: ()) -> Model {
207207
Model {
208208
counter: 0,
209209
}
@@ -253,7 +253,7 @@ impl Widget for Win {
253253
let Win { ref counter1, ref counter2, ref text, ref window, .. } = *win.borrow();
254254
connect!(text@Change(text), relm, TextChange(text));
255255
connect!(text@Change(_), counter1, with win_clone win_clone.inc());
256-
connect!(counter1@Increment, counter2, Increment);
256+
connect!(counter1@Increment, counter2, Decrement);
257257
connect!(button, connect_clicked(_), counter1, Decrement);
258258

259259
window.add(&hbox);
@@ -268,7 +268,7 @@ impl Widget for Win {
268268
}
269269

270270
impl Win {
271-
fn inc(&self) -> CounterMsg {
271+
fn inc(&mut self) -> CounterMsg {
272272
Increment
273273
}
274274
}

examples/container.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Widget for Button {
5555
type Msg = ();
5656
type Root = gtk::Button;
5757

58-
fn model(_: ()) -> () {
58+
fn model(_: &Relm<Self>, _: ()) -> () {
5959
}
6060

6161
fn root(&self) -> Self::Root {
@@ -92,7 +92,7 @@ impl Widget for VBox {
9292
type Msg = ();
9393
type Root = EventBox;
9494

95-
fn model(_: ()) -> () {
95+
fn model(_: &Relm<Self>, _: ()) -> () {
9696
()
9797
}
9898

@@ -131,7 +131,7 @@ impl Widget for Win {
131131
type Msg = Msg;
132132
type Root = Window;
133133

134-
fn model(_: ()) -> () {
134+
fn model(_: &Relm<Self>, _: ()) -> () {
135135
}
136136

137137
fn root(&self) -> Self::Root {

examples/generic-widget.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<T: Clone + IncDec + Display + 'static> Widget for Counter<T> {
8888
type Msg = CounterMsg<T>;
8989
type Root = gtk::Box;
9090

91-
fn model(value: T) -> Self::Model {
91+
fn model(_: &Relm<Self>, value: T) -> Self::Model {
9292
Model {
9393
counter: value,
9494
}
@@ -153,7 +153,7 @@ impl Widget for Win {
153153
type Msg = Msg;
154154
type Root = Window;
155155

156-
fn model(_: ()) -> () {
156+
fn model(_: &Relm<Self>, _: ()) -> () {
157157
()
158158
}
159159

examples/key-events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Widget for Win {
6060
type Msg = Msg;
6161
type Root = Window;
6262

63-
fn model(_: ()) -> Model {
63+
fn model(_: &Relm<Self>, _: ()) -> Model {
6464
Model {
6565
press_count: 0,
6666
}

examples/model-param.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Widget for Win {
6969
// Specify the type of the root widget.
7070
type Root = Window;
7171

72-
fn model(counter: i32) -> Model {
72+
fn model(_: &Relm<Self>, counter: i32) -> Model {
7373
Model {
7474
counter: counter,
7575
}

0 commit comments

Comments
 (0)