globalWatch<T> function
Create a watched variable from the variable v
,
a proxy object of the Type of Rx<T>
Implementation
Rx<T> globalWatch<T>(T v, {Object? tag}) {
final rx = Rx(v);
//* Check if the variable [Type] or the [tag] already exists
if (tag == null) {
if (!_globalWatchedVar.containsKey(T)) {
_globalWatchedVar[T] = rx;
// assert(() {
// print('Info: Global watched variable of Type: $T');
// return true;
// }());
}
/*
else {
assert(() {
print('Info: Global watched variable of Type: $T already exists.');
print(
'If the watched variable would be used across files, please use the [tag] parameter.');
return true;
}());
}
*/
} else {
if (!_globalWatchedVar.containsKey(tag)) {
_globalWatchedVar[tag] = rx;
} else {
throw FlutterError(
'Error: Global watched variable of tag:$tag already exists.');
}
}
return rx;
}