Last active
July 16, 2018 18:24
-
-
Save lukas-h/68877d87910d56367a691ad7a43a6b01 to your computer and use it in GitHub Desktop.
Dart Model View Control Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:html'; | |
import 'dart:math'; | |
class View{ | |
var button, text, listener; | |
View(Function f){ | |
button = querySelector("#button"); | |
text = querySelector("#text"); | |
listener = button.onClick.listen(f); | |
} | |
setText(String s){ | |
text.innerHtml = s; | |
} | |
} | |
class Model{ | |
final array = [ | |
"Hallo", | |
"Hi", | |
"Grüß Gott" | |
]; | |
getRandomData(){ | |
return array[new Random().nextInt(array.length)]; | |
} | |
} | |
class Controller{ | |
var view, model; | |
Controller(){ | |
model = new Model(); | |
view = new View((e){ | |
view.setText(model.getRandomData()); | |
}); | |
} | |
} | |
main() => new Controller(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id="button">Drücken!</button> | |
<span id="text"></> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment