fixed closure

This commit is contained in:
Devaev Maxim 2020-10-07 02:27:58 +03:00
parent bb68008f70
commit 6ae7adfb33

View File

@ -96,17 +96,21 @@ export function Gpio() {
for (let channel in model.scheme.outputs) { for (let channel in model.scheme.outputs) {
let el = $(`gpio-switch-${channel}`); let el = $(`gpio-switch-${channel}`);
if (el) { if (el) {
tools.setOnClick(el, () => __switchChannel(el)); tools.setOnClick(el, __createAction(el, __switchChannel));
} }
el = $(`gpio-button-${channel}`); el = $(`gpio-button-${channel}`);
if (el) { if (el) {
tools.setOnClick(el, () => __pulseChannel(el)); tools.setOnClick(el, __createAction(el, __pulseChannel));
} }
} }
self.setState(__state); self.setState(__state);
}; };
var __createAction = function(el, action) {
return () => action(el);
};
var __createItem = function(item) { var __createItem = function(item) {
if (item.type === "label") { if (item.type === "label") {
return item.text; return item.text;