rodydavis / signals.dart

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

"previousValue" getter does not on signal #218

Closed tdomarkas closed 3 months ago

tdomarkas commented 3 months ago

Code provided on https://github.com/rodydavis/signals.dart/blob/main/website/src/content/docs/dart/core/signal.md#previousvalue doesn't work as "previousValue" does not exist.

Is this just outdated documentation issue?

rodydavis commented 3 months ago

It should still be the case. It should only be removed for value signal.

I'll double check on the code and documentation

PaulHalliday commented 3 months ago

I can confirm on 4.5.1 that previousValue doesn't exist in the above case as per the documentation.

final counter = signal(0);

effect(() {
    print('Current value: ${counter.value}');
    print('Previous value: ${counter.previousValue}');
});

counter.value = 1;

---

The getter 'previousValue' isn't defined for the type 'Signal<int>'.
Try importing the library that defines 'previousValue', correcting the name to the name of an existing getter, or defining a getter or field named 'previousValue'.
rodydavis commented 3 months ago

Ah it is because I moved it to TrackedReadonlySignal and Signal does not expose it.

Just an interface issue, will fix it!

rodydavis commented 3 months ago

Will be fixed on the next release!

rodydavis commented 2 months ago

Added an error via mixin for the value signals on the latest beta