Consider adding a way to bind a value, computed based on other observable values
enhancementwontfix
As proposed by the @yousefak007 in https://github.com/s0nerik/context_plus/issues/12#issuecomment-2308998016, https://github.com/s0nerik/context_plus/issues/12#issuecomment-2309013971 and https://github.com/s0nerik/context_plus/issues/12#issuecomment-2311033969, this can probably be achieved with introduction of `Ref.bindProxy()` method with a specially-crafted type of `BuildContext` suitable for triggering the value re-computation without rebuilding the `context` upon a notification `.watch()`'ed from within the `create` callback. Proposed API:
```dart
T Ref.bindProxy(
context,
T Function(BuildContext context, T? previous) create, {
void Function(T value)? dispose,
Object? key,
});
```
Another option could be to add a `Ref.maybeOf(context)` method and just provide the special version of a `BuildContext` to the existing `Ref.bind()` and `Ref.bindLazy()` methods:
```dart
T Ref.bind(
context,
T Function(BuildContext context) create, {
void Function(T value)? dispose,
Object? key,
});
```
```dart
void Ref.bindLazy(
context,
T Function(BuildContext context) create, {
void Function(T value)? dispose,
Object? key,
});
```
关闭于 2025-05-03 5 条评论