本文整理汇总了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;
});