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