matthjes
12/18/2019, 9:24 AMclass NoteListViewModel : ViewModel() {
val notes: ObservableList<NoteViewModel> = observableListOf()
}
class NoteViewModel : ItemViewModel<Note>() {
val timestamp = bind(Note::timestamp)
val contentText = bind(Note::contentText)
val hashtags = bind(Note::hashtags)
fun parse(input: String) {
}
}
class Note(timestamp: Long = 0,
contentText: String = "",
hashtags: ObservableList<String> = observableListOf()) {
...
}
The idea is to let the user input the text and then call parse()
to extract the hashtags. The NoteViewModel
is injected into the input view, the NoteListViewModel
into the list view. Still I don't know how to connect both, maybe also inject the NoteViewModel
into the list view and rebind it when the user selects a note from the list to edit it?
How would I add a new note to the list of notes?