本文整理匯總了TypeScript中knockout.isSubscribable函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isSubscribable函數的具體用法?TypeScript isSubscribable怎麽用?TypeScript isSubscribable使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isSubscribable函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("should add immediate and dispose to given subscribable", () => {
const obs = ko.observable("test").extend({ delay: 10 }) as delayExtender.DelayedObservable<string>;
obs.immediate.should.be.a.Function;
ko.isSubscribable(obs.immediate).should.be.true;
obs.dispose.should.be.a.Function;
});
示例2: it
it("should return same value if given parameter is an observable", () => {
var value = ko.observable(commonHelpers.createNoteArray()),
result = utils.createObservable(value);
ko.isSubscribable(result).should.be.ok;
result.should.equal(value);
});
示例3: value
export function setMaybeObservable<T>(obj: Object, prop: string, newValue: T): void {
const value = obj[prop];
if (ko.isSubscribable(value)) {
value(newValue);
}
else {
obj[prop] = newValue;
}
}
示例4:
export function maybeObservable<T>(value: MaybeSubscribable<T>, _default?: T): MaybeSubscribable<T> {
if (typeof value === "undefined" || value === null) {
return _default;
}
if (ko.isSubscribable(value)) {
return value;
}
return value;
}
示例5: createObservableArray
export function createObservableArray(value: any, mapFunction?: (obj: any) => any, context?: any): ko.ObservableArray<any> {
if (typeof value === "undefined") {
return ko.observableArray();
}
if (ko.isSubscribable(value) && Array.isArray(value())) {
return value;
}
if (Array.isArray(value) && typeof mapFunction === "function") {
value = value.map(mapFunction, context);
}
return ko.observableArray(value);
}
示例6: it
it("should return a valid subscribable", () => {
hist = historyObservable();
ko.isSubscribable(hist).should.be.ok;
});