Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/v2.0.0 #85

Merged
merged 30 commits into from
May 30, 2024
Merged

feat/v2.0.0 #85

merged 30 commits into from
May 30, 2024

Conversation

nank1ro
Copy link
Owner

@nank1ro nank1ro commented Jan 2, 2024

  • CHORE: Improved Solid widget performance by more than 3000% in finding ancestor providers.
    During my performance tests, before I was able to observe up to 71 signals (provided through Solid) per second, now this numbers increased to 2159 signals per second.

  • FEAT: The SignalBuilder widget now automatically tracks the Signals used in the builder function 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 DualSignalBuilder and TripleSignalBuilder in favor of SignalBuilder.

  • BREAKING CHANGE the context.observe methods (due to the performance improvements of the Solid widget) now needs the type of signal
    Before:

    final counter = context.observe<int>();

    Now:

    final counter = context.observe<Signal<int>>().value;
  • BREAKING CHANGE: Removed ResourceBuilder in favor of SignalBuilder

  • FEAT: Add batch function to execute a callback that will not side-effect until its top-most batch is completed. See docs here

    The PR has still some problems:

    1. 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

@nank1ro nank1ro added the feature New feature or request label Jan 2, 2024
@nank1ro nank1ro self-assigned this Jan 2, 2024
@jinyus
Copy link

jinyus commented Jan 2, 2024

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
Copy link
Owner Author

nank1ro commented Jan 2, 2024

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
Copy link
Owner Author

nank1ro commented Jan 2, 2024

@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
Copy link

jinyus commented Jan 2, 2024

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

@nank1ro nank1ro changed the base branch from main to dev May 29, 2024 10:27
@nank1ro nank1ro marked this pull request as ready for review May 29, 2024 10:28
Copy link

codecov bot commented May 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (dev@e3bd529). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

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

@nank1ro nank1ro merged commit 8fb4cb3 into dev May 30, 2024
3 checks passed
@nank1ro nank1ro deleted the feat/v2.0.0 branch May 30, 2024 10:15
nank1ro added a commit that referenced this pull request Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants