rodydavis / signals.dart

Reactive programming made simple for Dart and Flutter
http://dartsignals.dev
Apache License 2.0
378 stars 44 forks source link

.watch(context) vs Watch differences #257

Closed PaulHalliday closed 3 days ago

PaulHalliday commented 2 months ago

I've been using signals/lite_ref in my project, and part of my implementation relies on overriding a scoped dependency to provide demo data for a "preview" mode of a particular set of widgets.

I ran into an issue where I had to replace my Watch for .watch(context) as it did not work correctly otherwise:

https://github.com/jinyus/lite_ref/issues/24

As I figured that Watch and .watch(context) were interchangeable (and especially considering the docs suggest using Watch over .watch(context)), are there any other/specific scenarios where this is expected?

rodydavis commented 2 months ago

The biggest difference is that Watch will rebuild for inherited widgets listened instead the callback (theme/media) and is an effect.

.watch calls the subscribe method for a specific signal.

That being said I am very interested and will see if we can get some tests added to make sure they are aligned as much as possible (inherited widgets will rebuild a lot more outside of my control).

rodydavis commented 2 months ago

Could you share a minimal example for reference?