feat/v2.0.0
-
CHORE: Improved
Solidwidget performance by more than 3000% in finding ancestor providers. During my performance tests, before I was able to observe up to71signals (provided through Solid) per second, now this numbers increased to2159signals per second. -
FEAT: The
SignalBuilderwidget now automatically tracks theSignals used in thebuilderfunction allowing you to react to any number of signals at the same time. Before:SignalBuilder( signal: counter, builder: (context, value, child) { return Text('$value'); }, ),Now:
SignalBuilder( builder: (context, child) { return Text('${counter.value}'); }, ), -
BREAKING CHANGE: Removed
DualSignalBuilderandTripleSignalBuilderin favor ofSignalBuilder. -
BREAKING CHANGE the
context.observemethods (due to the performance improvements of theSolidwidget) now needs the type of signal Before:final counter = context.observe<int>();Now:
final counter = context.observe<int, Signal<int>>(); // or final counter = context.observeSignal<int>();So this change includes the new
observeSignal,observeReadSignal,observeComputed,observeResource,observeListSignal,observeSetSignalandobserveMapSignalThe PR has still some problems:
- The auto dispose of signals happens when using
SignalBuilderbecause the effect tracks the dependencies in thebuildmethod. This is necessary to make it performant but, for a little moment, the signals will not be watched by theEffect. I still need to find a way to fix this. - I don't know if
context.observe<T, S>still be exposed, due to the new specific observe methods. - Still waiting for the v2 of SolidJS that may happen at the end of January 2024, this could improve the performance of the automatic tracking system significantly (https://github.com/bubblegroup/bubble-reactivity)
TODOs
- [ ] fix unit tests
- [ ] update solidart_lint
- [ ] update docs
- The auto dispose of signals happens when using
Note that SignalBuilder has a hidden footgun that will catch some users. Any signals accessed in its entire subtree will trigger a rebuild in the parent.
SignalBuilder
|_ Container
|_ Column
|_ SizedBox
|_ SignalBuilder
|_ Text <- signal watched here will rebuild both SignalBuilders
Note that
SignalBuilderhas a hidden footgun that will catch some users. Any signals accessed in its entire subtree will trigger a rebuild in the parent.SignalBuilder |_ Container |_ Column |_ SizedBox |_ SignalBuilder |_ Text <- signal watched here will rebuild both SignalBuilders
Thanks for reporting 🙏, need to investigate further to fix this
@jinyus can't reproduce the issue, this is the code I used to test
import 'package:flutter/material.dart';
import 'package:flutter_solidart/flutter_solidart.dart';
final a = Signal(0);
final b = Signal(100);
class TestPage extends StatelessWidget {
const TestPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: SignalBuilder(
builder: (_, __) {
print('build a');
return Column(
children: [
Text(a().toString()),
const Second(),
],
);
},
),
floatingActionButton: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextButton(
onPressed: () => a.value++,
child: const Text('add to A'),
),
TextButton(
onPressed: () => b.value++,
child: const Text('add to B'),
),
],
),
);
}
}
class Second extends StatelessWidget {
const Second({super.key});
@override
Widget build(BuildContext context) {
return SignalBuilder(
builder: (_, __) {
print('build b');
return Text(b().toString());
},
);
}
}
Can you share your code please?
I'm no longer seeing this bug. I will have to investigate further. Consider this a non-issue for now.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Please upload report for BASE (
dev@e3bd529). Learn more about missing BASE report.
Additional details and impacted files
@@ Coverage Diff @@
## dev #85 +/- ##
=======================================
Coverage ? 100.00%
=======================================
Files ? 21
Lines ? 1166
Branches ? 0
=======================================
Hits ? 1166
Misses ? 0
Partials ? 0
| Files | Coverage Δ | |
|---|---|---|
| ...utter_solidart/lib/src/utils/solid_extensions.dart | 100.00% <100.00%> (ø) |
|
| ...ackages/flutter_solidart/lib/src/widgets/show.dart | 100.00% <100.00%> (ø) |
|
| ...utter_solidart/lib/src/widgets/signal_builder.dart | 100.00% <100.00%> (ø) |
|
| ...ckages/flutter_solidart/lib/src/widgets/solid.dart | 100.00% <100.00%> (ø) |
|
| packages/solidart/lib/src/core/atom.dart | 100.00% <100.00%> (ø) |
|
| packages/solidart/lib/src/core/batch.dart | 100.00% <100.00%> (ø) |
|
| packages/solidart/lib/src/core/effect.dart | 100.00% <100.00%> (ø) |
|
| ...ckages/solidart/lib/src/core/reactive_context.dart | 100.00% <100.00%> (ø) |
|
| packages/solidart/lib/src/core/read_signal.dart | 100.00% <100.00%> (ø) |
|
| packages/solidart/lib/src/core/resource.dart | 100.00% <ø> (ø) |
|
| ... and 1 more |