poker-html-client
Version:
HTML client for online poker
23 lines (19 loc) • 706 B
text/typescript
/* tslint:disable:no-string-literal */
import * as ko from "knockout";
export function registerExtenders() {
ko.extenders["options"] = (target, option: { caption: string; items: SelectorItem[]}) => {
target.options = option.items;
target.caption = option.caption;
target.currentValue = ko.computed(() => {
const value = target();
const selectedItem = option.items.filter((item: SelectorItem) => {
return item.value === value;
});
if (selectedItem.length === 0) {
return "";
}
return selectedItem[0].text;
});
return target;
};
}