Use MappedList instead of MappedMap
- MappedList supports an optional updater method Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
b62473ae79
commit
0819dcb29e
1 changed files with 8 additions and 5 deletions
|
@ -1,12 +1,13 @@
|
|||
import {ViewModel} from "../../ViewModel.js";
|
||||
import {MemberTileViewModel} from "./MemberTileViewModel.js";
|
||||
import {createMemberComparator} from "./comparator.js";
|
||||
import {MappedList} from "../../../observable/list/MappedList.js";
|
||||
|
||||
export class MemberListViewModel extends ViewModel {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.memberTileViewModels = this._mapTileViewModels(this._filterJoinedMembers(options.members))
|
||||
.sortValues(createMemberComparator(options.powerLevels));
|
||||
this.memberTileViewModels = this._mapTileViewModels(this._filterJoinedMembers(options.members)
|
||||
.sortValues(createMemberComparator(options.powerLevels)));
|
||||
}
|
||||
|
||||
_filterJoinedMembers(members) {
|
||||
|
@ -14,8 +15,10 @@ export class MemberListViewModel extends ViewModel {
|
|||
}
|
||||
|
||||
_mapTileViewModels(members) {
|
||||
return members.mapValues((member, emitChange) => {
|
||||
return new MemberTileViewModel(this.childOptions({member, emitChange}));
|
||||
});
|
||||
const mapper = (member) => {
|
||||
return new MemberTileViewModel(this.childOptions({member}));
|
||||
}
|
||||
const updater = (vm, params, newMember) => vm.updateFrom(newMember);
|
||||
return new MappedList(members, mapper, updater);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue