【发布时间】:2016-03-08 05:55:09
【问题描述】:
有几个关于这个主题的教程和示例,但它们都是一种通用构建,仅在一个类中展示它的一般工作原理。
所以我的问题是什么时候我想遵循 MVVM 模式,我必须实现我的所有任务?
鉴于以下情况:
型号:
class Model {
/* When I place the Task here how can I deal with arguments and results from ViewController? */
public BufferedImage bigTask (String this, String and, Image that){
// Some code to build a BufferedImage
}
}
视图模型:
class ViewController {
private BufferedImage myBufferedImage;
@FXML
private Button aButton;
/*Should I implement my Task here? But how I get information about progress? */
final Task<Integer> myTask = new Task<Integer>(){
@Override
protected Integer call() throws Exception{
updateProgress( // How to get here? Is it the right place? )
return null;
}
};
@FXML
void setOnAction(ActionEvent actionEvent){
myBufferedImage = Model.bigTask("this", "that", new Image("path"));
}
}
希望我能解释这个问题。
提前致谢!
【问题讨论】:
-
只是为了确保:该图像不是模型的一部分,而是基于模型数据的数据?
标签: mvvm javafx task viewmodel worker