rx_interface.dart
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import 'dart:async';
import 'package:get/src/rx/rx_callbacks.dart';
import 'package:get/src/rx/rx_model.dart';
abstract class RxInterface<T> {
RxInterface([T initial]);
/// Get current value
get v;
/// Set value
set v(T val);
/// Cast [val] to [T] before setting
void setCast(dynamic /* T */ val);
/// Stream of record of [Change]s of value
// Stream<Change<T>> get onChange;
/// add listener to stream
addListener(Stream<Change<T>> rxGetx);
/// close stream
close() {
subject?.close();
}
StreamController<Change<T>> subject;
/// Stream of changes of value
Stream<T> get stream;
/// Convert value on string
// String get string;
/// Binds if [other] is [Stream] or [RxInterface] of type [T]. Sets if [other] is
/// instance of [T]
void bindOrSet(/* T | Stream<T> | Reactive<T> */ other);
/// Binds [other] to this
void bind(RxInterface<T> other);
/// Binds the [stream] to this
void bindStream(Stream<T> stream);
/// Calls [callback] with current value, when the value changes.
StreamSubscription<T> listen(ValueCallback<T> callback);
/// Maps the changes into a [Stream] of [S]
// Stream<S> map<S>(S mapper(T data));
}
class RxController implements DisposableInterface {
void onInit() async {}
void onClose() async {}
}
abstract class DisposableInterface {
void onClose() async {}
void onInit() async {}
}