nank1ro / solidart

Signals in Dart and Flutter, inspired by SolidJS
https://docs.page/nank1ro/solidart
MIT License
163 stars 7 forks source link

feat/v2.0.0 #85

Closed nank1ro closed 5 months ago

nank1ro commented 10 months ago
jinyus commented 10 months ago

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
nank1ro commented 10 months ago

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

Thanks for reporting 🙏, need to investigate further to fix this

nank1ro commented 10 months ago

@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?

jinyus commented 10 months ago

I'm no longer seeing this bug. I will have to investigate further. Consider this a non-issue for now.

codecov[bot] commented 5 months ago

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 [![Impacted file tree graph](https://app.codecov.io/gh/nank1ro/solidart/pull/85/graphs/tree.svg?width=650&height=150&src=pr&token=HvJYtaixiW&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti)](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti) ```diff @@ Coverage Diff @@ ## dev #85 +/- ## ======================================= Coverage ? 100.00% ======================================= Files ? 21 Lines ? 1166 Branches ? 0 ======================================= Hits ? 1166 Misses ? 0 Partials ? 0 ``` | [Files](https://app.codecov.io/gh/nank1ro/solidart/pull/85?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti) | Coverage Δ | | |---|---|---| | [...utter\_solidart/lib/src/utils/solid\_extensions.dart](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&filepath=packages%2Fflutter_solidart%2Flib%2Fsrc%2Futils%2Fsolid_extensions.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti#diff-cGFja2FnZXMvZmx1dHRlcl9zb2xpZGFydC9saWIvc3JjL3V0aWxzL3NvbGlkX2V4dGVuc2lvbnMuZGFydA==) | `100.00% <100.00%> (ø)` | | | [...ackages/flutter\_solidart/lib/src/widgets/show.dart](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&filepath=packages%2Fflutter_solidart%2Flib%2Fsrc%2Fwidgets%2Fshow.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti#diff-cGFja2FnZXMvZmx1dHRlcl9zb2xpZGFydC9saWIvc3JjL3dpZGdldHMvc2hvdy5kYXJ0) | `100.00% <100.00%> (ø)` | | | [...utter\_solidart/lib/src/widgets/signal\_builder.dart](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&filepath=packages%2Fflutter_solidart%2Flib%2Fsrc%2Fwidgets%2Fsignal_builder.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti#diff-cGFja2FnZXMvZmx1dHRlcl9zb2xpZGFydC9saWIvc3JjL3dpZGdldHMvc2lnbmFsX2J1aWxkZXIuZGFydA==) | `100.00% <100.00%> (ø)` | | | [...ckages/flutter\_solidart/lib/src/widgets/solid.dart](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&filepath=packages%2Fflutter_solidart%2Flib%2Fsrc%2Fwidgets%2Fsolid.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti#diff-cGFja2FnZXMvZmx1dHRlcl9zb2xpZGFydC9saWIvc3JjL3dpZGdldHMvc29saWQuZGFydA==) | `100.00% <100.00%> (ø)` | | | [packages/solidart/lib/src/core/atom.dart](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&filepath=packages%2Fsolidart%2Flib%2Fsrc%2Fcore%2Fatom.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti#diff-cGFja2FnZXMvc29saWRhcnQvbGliL3NyYy9jb3JlL2F0b20uZGFydA==) | `100.00% <100.00%> (ø)` | | | [packages/solidart/lib/src/core/batch.dart](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&filepath=packages%2Fsolidart%2Flib%2Fsrc%2Fcore%2Fbatch.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti#diff-cGFja2FnZXMvc29saWRhcnQvbGliL3NyYy9jb3JlL2JhdGNoLmRhcnQ=) | `100.00% <100.00%> (ø)` | | | [packages/solidart/lib/src/core/effect.dart](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&filepath=packages%2Fsolidart%2Flib%2Fsrc%2Fcore%2Feffect.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti#diff-cGFja2FnZXMvc29saWRhcnQvbGliL3NyYy9jb3JlL2VmZmVjdC5kYXJ0) | `100.00% <100.00%> (ø)` | | | [...ckages/solidart/lib/src/core/reactive\_context.dart](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&filepath=packages%2Fsolidart%2Flib%2Fsrc%2Fcore%2Freactive_context.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti#diff-cGFja2FnZXMvc29saWRhcnQvbGliL3NyYy9jb3JlL3JlYWN0aXZlX2NvbnRleHQuZGFydA==) | `100.00% <100.00%> (ø)` | | | [packages/solidart/lib/src/core/read\_signal.dart](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&filepath=packages%2Fsolidart%2Flib%2Fsrc%2Fcore%2Fread_signal.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti#diff-cGFja2FnZXMvc29saWRhcnQvbGliL3NyYy9jb3JlL3JlYWRfc2lnbmFsLmRhcnQ=) | `100.00% <100.00%> (ø)` | | | [packages/solidart/lib/src/core/resource.dart](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree&filepath=packages%2Fsolidart%2Flib%2Fsrc%2Fcore%2Fresource.dart&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti#diff-cGFja2FnZXMvc29saWRhcnQvbGliL3NyYy9jb3JlL3Jlc291cmNlLmRhcnQ=) | `100.00% <ø> (ø)` | | | ... and [1 more](https://app.codecov.io/gh/nank1ro/solidart/pull/85?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Alexandru+Mariuti) | |