Line data Source code
1 : import 'dart:async'; 2 : import 'package:flutter/scheduler.dart'; 3 : import 'package:get/src/state_manager/rx/rx_callbacks.dart'; 4 : 5 : abstract class RxInterface<T> { 6 3 : RxInterface([T initial]); 7 : 8 : /// add listener to stream 9 : addListener(Stream<T> rxGetx); 10 : 11 : /// close stream 12 0 : close() { 13 0 : subject?.close(); 14 : } 15 : 16 : StreamController<T> subject; 17 : 18 : /// Convert value on string 19 : // String get string; 20 : 21 : /// Calls [callback] with current value, when the value changes. 22 : StreamSubscription<T> listen(ValueCallback<T> callback); 23 : 24 : /// Maps the changes into a [Stream] of [S] 25 : // Stream<S> map<S>(S mapper(T data)); 26 : } 27 : 28 : abstract class DisposableInterface { 29 : /// Called at the exact moment that the widget is allocated in memory. 30 : /// Do not overwrite this method. 31 7 : void onStart() { 32 7 : onInit(); 33 25 : SchedulerBinding.instance?.addPostFrameCallback((_) => onReady()); 34 : } 35 : 36 : /// Called Called immediately after the widget is allocated in memory. 37 0 : void onInit() async {} 38 : 39 : /// Called after rendering the screen. It is the perfect place to enter navigation events, 40 : /// be it snackbar, dialogs, or a new route. 41 0 : void onReady() async {} 42 : 43 : /// Called before the onDelete method. onClose is used to close events 44 : /// before the controller is destroyed, such as closing streams, for example. 45 0 : onClose() async {} 46 : }