selectObserve<S> method

SignalsWatch<S> selectObserve<S>(
  1. S selector(
    1. dynamic
    ),
  2. Widget builder(
    1. S
    ), {
  3. Key? key,
  4. void onInit(
    1. S value
    )?,
  5. Function? onValueUpdated,
  6. void onAfterBuild(
    1. S value
    )?,
  7. void onDispose(
    1. S value
    )?,
  8. bool shouldRebuild(
    1. S newValue,
    2. S oldValue
    )?,
  9. bool shouldNotify(
    1. S newValue,
    2. S oldValue
    )?,
  10. bool equals(
    1. S a,
    2. S b
    )?,
  11. Duration? debounce,
  12. Duration? throttle,
  13. void onError(
    1. Object error,
    2. StackTrace stack
    )?,
  14. Widget errorBuilder(
    1. Object error
    )?,
  15. Widget loadingBuilder()?,
  16. String? debugLabel,
  17. bool debugPrint = false,
})

Select a specific part of this signal's value and only rebuild when that part changes.

Example:

final user = SignalsWatch.signal(User(name: 'John', age: 25));

// Only rebuilds when age changes, ignores name changes
user.selectObserve(
  (user) => user.age,
  (age) => Text('Age: $age'),
)

Implementation

SignalsWatch<S> selectObserve<S>(
  S Function(dynamic) selector,
  Widget Function(S) builder, {
  Key? key,
  void Function(S value)? onInit,
  Function? onValueUpdated,
  void Function(S value)? onAfterBuild,
  void Function(S value)? onDispose,
  bool Function(S newValue, S oldValue)? shouldRebuild,
  bool Function(S newValue, S oldValue)? shouldNotify,
  bool Function(S a, S b)? equals,
  Duration? debounce,
  Duration? throttle,
  void Function(Object error, StackTrace stack)? onError,
  Widget Function(Object error)? errorBuilder,
  Widget Function()? loadingBuilder,
  String? debugLabel,
  bool debugPrint = false,
}) {
  return SignalsWatch<S>.select(
    this,
    selector: selector,
    key: key,
    builder: builder,
    onInit: onInit,
    onValueUpdated: onValueUpdated,
    onAfterBuild: onAfterBuild,
    onDispose: onDispose,
    shouldRebuild: shouldRebuild,
    shouldNotify: shouldNotify,
    equals: equals,
    debounce: debounce,
    throttle: throttle,
    onError: onError,
    errorBuilder: errorBuilder,
    loadingBuilder: loadingBuilder,
    debugLabel: debugLabel,
    debugPrint: debugPrint,
  );
}