Added isFunction()

This commit is contained in:
djmaze 2021-03-24 14:22:25 +01:00
parent 658ac816c8
commit fe4dbc729c
6 changed files with 13 additions and 21 deletions

View file

@ -1,7 +1,7 @@
import { isArray, addObservablesTo, addComputablesTo } from 'Common/Utils';
import { isArray, isFunction, addObservablesTo, addComputablesTo } from 'Common/Utils';
function dispose(disposable) {
if (disposable && 'function' === typeof disposable.dispose) {
if (disposable && isFunction(disposable.dispose)) {
disposable.dispose();
}
}

View file

@ -1,7 +1,7 @@
import ko from 'ko';
import { doc, $htmlCL } from 'Common/Globals';
import { isNonEmptyArray } from 'Common/Utils';
import { isNonEmptyArray, isFunction } from 'Common/Utils';
let currentScreen = null,
defaultScreenName = '';
@ -39,7 +39,7 @@ export function createCommand(fExecute, fCanExecute = true) {
fResult.enabled = ko.observable(true);
fResult.isCommand = true;
if (typeof fCanExecute === 'function') {
if (isFunction(fCanExecute)) {
fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && fCanExecute.call(null));
} else {
fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && !!fCanExecute);