Skip to content

Commit 5d80367

Browse files
committed
formatted files
1 parent 43fb97e commit 5d80367

File tree

12 files changed

+158
-106
lines changed

12 files changed

+158
-106
lines changed

‎packages/preact_signals/test/batch_test.dart‎

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ void main() {
1212
});
1313

1414
test('should throw errors thrown from the callback', () {
15-
expect(() {
16-
batch(() {
17-
throw Exception('hello');
18-
});
19-
}, throwsException,);
15+
expect(
16+
() {
17+
batch(() {
18+
throw Exception('hello');
19+
});
20+
},
21+
throwsException,
22+
);
2023
});
2124

2225
test('should throw non-errors thrown from the callback', () {
@@ -185,13 +188,16 @@ void main() {
185188
spy1.resetHistory();
186189
spy2.resetHistory();
187190

188-
expect(() {
189-
batch(() {
190-
a.value++;
191-
b.value++;
192-
throw Exception('hello');
193-
});
194-
}, throwsException,);
191+
expect(
192+
() {
193+
batch(() {
194+
a.value++;
195+
b.value++;
196+
throw Exception('hello');
197+
});
198+
},
199+
throwsException,
200+
);
195201

196202
expect(spy1.calls, 1);
197203
expect(spy2.calls, 1);
@@ -220,11 +226,14 @@ void main() {
220226
spy1.resetHistory();
221227
spy2.resetHistory();
222228

223-
expect(() {
224-
batch(() {
225-
a.value++;
226-
});
227-
}, throwsException,);
229+
expect(
230+
() {
231+
batch(() {
232+
a.value++;
233+
});
234+
},
235+
throwsException,
236+
);
228237

229238
expect(spy1.calls, 1);
230239
expect(spy2.calls, 1);

‎packages/signals_core/lib/src/async/stream.dart‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,11 @@ class StreamSignal<T> extends AsyncSignal<T> {
239239
return fn();
240240
},
241241
),
242-
super(initialValue != null
243-
? AsyncState.data(initialValue)
244-
: AsyncState.loading(),) {
242+
super(
243+
initialValue != null
244+
? AsyncState.data(initialValue)
245+
: AsyncState.loading(),
246+
) {
245247
if (!lazy) value;
246248
}
247249

‎packages/signals_core/test/async/state_test.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void main() {
152152
expect(value, true);
153153
});
154154
});
155-
155+
156156
group('pattern matching', () {
157157
test('loading', () {
158158
final s = AsyncState<int>.loading();

‎packages/signals_core/test/persisted/signal_test.dart‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ void main() {
125125
group('PersistedPersistedEnumSignal', () {
126126
test('it should persist a nullable enum value', () async {
127127
final signal = PersistedPersistedEnumSignal(
128-
TestEnum.a, 'nullable_enum_key', TestEnum.values,);
128+
TestEnum.a,
129+
'nullable_enum_key',
130+
TestEnum.values,
131+
);
129132
await signal.init();
130133
expect(signal.value, TestEnum.a);
131134

@@ -135,7 +138,10 @@ void main() {
135138
expect(item, '');
136139

137140
final signal2 = PersistedPersistedEnumSignal(
138-
TestEnum.a, 'nullable_enum_key', TestEnum.values,);
141+
TestEnum.a,
142+
'nullable_enum_key',
143+
TestEnum.values,
144+
);
139145
await signal2.init();
140146
expect(signal2.value, null);
141147
});

‎packages/signals_flutter/example/lib/examples/redux.dart‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ AppState reducer(AppState state, AppAction action) {
4343
state.searchQuery,
4444
),
4545
UpdateItemAction action => AppState(
46-
List.from(state.items)
47-
..[action.index] = action.item,
46+
List.from(state.items)..[action.index] = action.item,
4847
state.searchQuery,
4948
),
5049
PerformSearchAction action => AppState(state.items, action.query),
@@ -119,7 +118,8 @@ class Example extends StatelessWidget {
119118
key: ValueKey((store.items.value.length, index)),
120119
title: TextFormField(
121120
initialValue: item,
122-
onChanged: (val) => store.dispatch(UpdateItemAction(index, val)),
121+
onChanged: (val) =>
122+
store.dispatch(UpdateItemAction(index, val)),
123123
),
124124
trailing: IconButton(
125125
icon: const Icon(Icons.delete),

‎packages/signals_flutter/lib/extended.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export 'src/extended/widgets.dart';
55
export 'src/extended/material.dart';
66
export 'src/extended/widgets_binding.dart';
77
export 'src/extended/scheduler_binding.dart';
8-
export 'src/extensions/untracked_value.dart';
8+
export 'src/extensions/untracked_value.dart';

‎packages/signals_flutter/lib/src/mixins/signals.dart‎

Lines changed: 80 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,15 @@ mixin SignalsMixin<T extends StatefulWidget> on State<T> {
118118
String? debugLabel,
119119
bool lazy = true,
120120
}) {
121-
return _bindLocal(computedFrom<S, A>(
122-
signals,
123-
fn,
124-
initialValue: initialValue,
125-
debugLabel: debugLabel,
126-
lazy: lazy,
127-
),);
121+
return _bindLocal(
122+
computedFrom<S, A>(
123+
signals,
124+
fn,
125+
initialValue: initialValue,
126+
debugLabel: debugLabel,
127+
lazy: lazy,
128+
),
129+
);
128130
}
129131

130132
/// Async Computed is syntax sugar around [FutureSignal].
@@ -149,13 +151,15 @@ mixin SignalsMixin<T extends StatefulWidget> on State<T> {
149151
List<ReadonlySignal<dynamic>> dependencies = const [],
150152
bool lazy = true,
151153
}) {
152-
return _bindLocal(computedAsync<S>(
153-
fn,
154-
dependencies: dependencies,
155-
initialValue: initialValue,
156-
debugLabel: debugLabel,
157-
lazy: lazy,
158-
),);
154+
return _bindLocal(
155+
computedAsync<S>(
156+
fn,
157+
dependencies: dependencies,
158+
initialValue: initialValue,
159+
debugLabel: debugLabel,
160+
lazy: lazy,
161+
),
162+
);
159163
}
160164

161165
/// Create a signal from a future
@@ -166,13 +170,15 @@ mixin SignalsMixin<T extends StatefulWidget> on State<T> {
166170
List<ReadonlySignal<dynamic>> dependencies = const [],
167171
bool lazy = true,
168172
}) {
169-
return _bindLocal(futureSignal<S>(
170-
fn,
171-
initialValue: initialValue,
172-
debugLabel: debugLabel,
173-
dependencies: dependencies,
174-
lazy: lazy,
175-
),);
173+
return _bindLocal(
174+
futureSignal<S>(
175+
fn,
176+
initialValue: initialValue,
177+
debugLabel: debugLabel,
178+
dependencies: dependencies,
179+
lazy: lazy,
180+
),
181+
);
176182
}
177183

178184
/// Create a signals from a stream
@@ -185,92 +191,108 @@ mixin SignalsMixin<T extends StatefulWidget> on State<T> {
185191
bool? cancelOnError,
186192
bool lazy = true,
187193
}) {
188-
return _bindLocal(streamSignal<S>(
189-
callback,
190-
initialValue: initialValue,
191-
debugLabel: debugLabel,
192-
dependencies: dependencies,
193-
onDone: onDone,
194-
cancelOnError: cancelOnError,
195-
lazy: lazy,
196-
),);
194+
return _bindLocal(
195+
streamSignal<S>(
196+
callback,
197+
initialValue: initialValue,
198+
debugLabel: debugLabel,
199+
dependencies: dependencies,
200+
onDone: onDone,
201+
cancelOnError: cancelOnError,
202+
lazy: lazy,
203+
),
204+
);
197205
}
198206

199207
/// Create a signal holding an async value
200208
AsyncSignal<S> createAsyncSignal<S>(
201209
AsyncState<S> value, {
202210
String? debugLabel,
203211
}) {
204-
return _bindLocal(asyncSignal<S>(
205-
value,
206-
debugLabel: debugLabel,
207-
),);
212+
return _bindLocal(
213+
asyncSignal<S>(
214+
value,
215+
debugLabel: debugLabel,
216+
),
217+
);
208218
}
209219

210220
/// Create a signal<T> and watch for changes
211221
FlutterSignal<V> createSignal<V>(
212222
V val, {
213223
String? debugLabel,
214224
}) {
215-
return _bindLocal(signal<V>(
216-
val,
217-
debugLabel: debugLabel,
218-
),);
225+
return _bindLocal(
226+
signal<V>(
227+
val,
228+
debugLabel: debugLabel,
229+
),
230+
);
219231
}
220232

221233
/// Create a [ListSignal]<T> and watch for changes
222234
ListSignal<V> createListSignal<V>(
223235
List<V> list, {
224236
String? debugLabel,
225237
}) {
226-
return _bindLocal(ListSignal<V>(
227-
list,
228-
debugLabel: debugLabel,
229-
),);
238+
return _bindLocal(
239+
ListSignal<V>(
240+
list,
241+
debugLabel: debugLabel,
242+
),
243+
);
230244
}
231245

232246
/// Create a [SetSignal]<T> and watch for changes
233247
SetSignal<V> createSetSignal<V>(
234248
Set<V> set, {
235249
String? debugLabel,
236250
}) {
237-
return _bindLocal(SetSignal<V>(
238-
set,
239-
debugLabel: debugLabel,
240-
),);
251+
return _bindLocal(
252+
SetSignal<V>(
253+
set,
254+
debugLabel: debugLabel,
255+
),
256+
);
241257
}
242258

243259
/// Create a [QueueSignal]<T> and watch for changes
244260
QueueSignal<V> createQueueSignal<V>(
245261
Queue<V> queue, {
246262
String? debugLabel,
247263
}) {
248-
return _bindLocal(QueueSignal<V>(
249-
queue,
250-
debugLabel: debugLabel,
251-
),);
264+
return _bindLocal(
265+
QueueSignal<V>(
266+
queue,
267+
debugLabel: debugLabel,
268+
),
269+
);
252270
}
253271

254272
/// Create a [MapSignal]<T> and watch for changes
255273
MapSignal<K, V> createMapSignal<K, V>(
256274
Map<K, V> value, {
257275
String? debugLabel,
258276
}) {
259-
return _bindLocal(MapSignal<K, V>(
260-
value,
261-
debugLabel: debugLabel,
262-
),);
277+
return _bindLocal(
278+
MapSignal<K, V>(
279+
value,
280+
debugLabel: debugLabel,
281+
),
282+
);
263283
}
264284

265285
/// Create a computed<T> and watch for changes
266286
FlutterComputed<V> createComputed<V>(
267287
V Function() cb, {
268288
String? debugLabel,
269289
}) {
270-
return _bindLocal(computed<V>(
271-
cb,
272-
debugLabel: debugLabel,
273-
),);
290+
return _bindLocal(
291+
computed<V>(
292+
cb,
293+
debugLabel: debugLabel,
294+
),
295+
);
274296
}
275297

276298
S _bindLocal<V, S extends ReadonlySignal<V>>(S val) {

‎packages/signals_flutter/lib/src/watch/builder.dart‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ class WatchBuilder<T extends Widget> extends StatefulWidget {
6464

6565
class _WatchState<T extends Widget> extends State<WatchBuilder<T>>
6666
with SignalsMixin {
67-
late final result = createComputed(() {
68-
return widget.builder(context, widget.child);
69-
}, debugLabel: widget.debugLabel,);
67+
late final result = createComputed(
68+
() {
69+
return widget.builder(context, widget.child);
70+
},
71+
debugLabel: widget.debugLabel,
72+
);
7073
bool _init = true;
7174

7275
@override

‎packages/signals_flutter/test/extension/value_listenable_test.dart‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
33
import 'package:signals_flutter/signals_flutter.dart';
44

55
void main() {
6-
testWidgets('ValueListenable.toSignal() disposes listener',
7-
(tester) async {
6+
testWidgets('ValueListenable.toSignal() disposes listener', (tester) async {
87
final listenable = ValueNotifier(0);
98
final signal = listenable.toSignal();
109

0 commit comments

Comments
 (0)