Skip to content

Instantly share code, notes, and snippets.

@toori67
Created March 14, 2017 16:41
Show Gist options
  • Save toori67/11db8878568fc6eb9df2ccba3c017b20 to your computer and use it in GitHub Desktop.
Save toori67/11db8878568fc6eb9df2ccba3c017b20 to your computer and use it in GitHub Desktop.
android mvvm
interface ICommand {
String getKey();
void onChange(Map<String, Object> props);
}
class NotifyTextView extends TextView implements ICommand {
...
@Override
public String getKey() {
return "topic";
}
@Override
public void onChange(Map<String, Object> props) {
setText((String) props.get("topic"))
}
}
class Presenter {
Map<String, List<ICommand>> keyViewMap;
public onTopicChange(Map<String, Object> props) {
...
for command : keyViewMap.get("topic") {
command.onChange(props);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment