Search
 
SCRIPT & CODE EXAMPLE
 

DART

how to add a listner to a object in dart

import 'dart:async';

class BaseModel {
  Map objects;
  StreamController fetchDoneController = new StreamController.broadcast();

  // define constructor here

  fetch() {
    // fetch json from server and then load it to objects
    // emits an event here
    fetchDoneController.add("all done"); // send an arbitrary event
  }

  Stream get fetchDone => fetchDoneController.stream;

}


// over in youre app file

main() {
  var model = new BaseModel();
  model.fetchDone.listen((_) => doCoolStuff(model));
}
Comment

PREVIOUS NEXT
Code Example
Dart :: automatic keepalive flutter tabs 
Dart :: missingpluginexceptionno implementation found for method firebaseinitializecore 
Dart :: dart list join 
Dart :: how to remove listtile long pressflutter 
Dart :: glowing buttons in flutter 
Dart :: dart rob cross axis align not work 
Dart :: dart code examples 
Dart :: customscrollview add container widget 
Swift :: firebase crashlytics dsym missing 
Swift :: swift 5 get current year 
Swift :: change from Date to String swift 5 
Swift :: find object in array by property swift 
Swift :: playing a sound in swift 
Swift :: swft imageä 
Swift :: quartzcore framework pi chart 
Swift :: swift temporary directory 
Swift :: swift javascript injection 
Swift :: swiftui scrollview hide scrollbar 
Swift :: swift email regex 
Swift :: swiftui pull to refresh 
Swift :: swiftui scrollview 
Swift :: get day difference between two dates swift 
Swift :: custom tab bar swift ios 
Swift :: rxswift combine two observables 
Swift :: remove all add TapGestureRecognizer swift 
Swift :: swift constructor 
Swift :: Nested if...else Statement 
Swift :: Swift Class and Objects 
Swift :: abstract class in swift 
Swift :: swift comment 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =