本文整理汇总了TypeScript中knockout.unwrap函数的典型用法代码示例。如果您正苦于以下问题:TypeScript unwrap函数的具体用法?TypeScript unwrap怎么用?TypeScript unwrap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unwrap函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: unwrap
var _selected = selectOptions.filter(item => {
if (allBindings.optionsValue) {
var optionsValue = unwrap(allBindings.optionsValue);
if (typeof (optionsValue) === "string") {
return unwrap(item[optionsValue]) === value;
}
else if (typeof (optionsValue) === "function") {
return unwrap(optionsValue.call(null, item)) === value;
}
}
return item === value;
})[0];
开发者ID:spatools,项目名称:kohandlers,代码行数:13,代码来源:ui.ts
示例2: function
init: function (element, valueAccessor) {
const $element = $(element);
let value = valueAccessor(),
options = ko.unwrap(value),
id = $element.attr("id"),
oldSetup, editor;
if (typeof options === "object") {
value = options.value;
delete options.value;
}
else {
options = {};
}
if (!id) {
id = tinymce.DOM.uniqueId();
$element.attr("id", id);
}
ko.utils.extend(options, defaults);
oldSetup = options.setup;
options.setup = (editor) => {
oldSetup && oldSetup.call(undefined, editor);
};
if ($element.is("textarea"))
$element.val(ko.unwrap(value));
else {
$element.html(ko.unwrap(value));
options.inline = true;
}
editor = new tinymce.Editor(id, options, tinymce.EditorManager);
editor.on("change keyup nodechange", () => {
if (ko.isWriteableObservable(value)) value(editor.getContent());
});
// To prevent a memory leak, ensure that the underlying element"s disposal destroys it"s associated editor.
ko.utils.domNodeDisposal.addDisposeCallback(element, () => {
if (editor) {
editor.remove();
editor = null;
}
});
editor.render();
},
开发者ID:spatools,项目名称:koui,代码行数:49,代码来源:tinymce.ts
示例3: update
update(element: HTMLElement, valueAccessor: () => KnockoutObservable<string>) {
var text = ko.unwrap(valueAccessor());
text = fixLinks(text, false);
var nickname = authentication.account().userName();
text = text.replace('@' + nickname, '<strong>@' + nickname + '</strong>');
element.innerHTML = text;
}
开发者ID:folkelib,项目名称:folke-forum,代码行数:7,代码来源:ko-extensions.ts
示例4: merge
export default function merge(
dest: PlainObject,
src: PlainObject,
mapArraysDeep: boolean = false
): KnockoutObservableTree {
const props = Object.keys(src)
for (const prop of props) {
if (isUndefined(dest[prop])) {
dest[prop] = fromJS(src[prop], src[prop] instanceof Array && mapArraysDeep)
} else if (ko.isObservable(dest[prop])) {
dest[prop](
src[prop] instanceof Array && mapArraysDeep
? ko.unwrap(fromJS(src[prop], true))
: src[prop]
)
} else if (isUndefined(src[prop])) {
dest[prop] = undefined
} else if (src[prop].constructor === Object) {
merge(dest[prop], src[prop], mapArraysDeep)
} else {
dest[prop] = src[prop]
}
}
return dest
}
开发者ID:Profiscience,项目名称:ko-contrib-utils,代码行数:27,代码来源:merge.ts
示例5:
static push_and_remove<T> (array : ko.MaybeObservableArray<T>, data: T, plot_size : number)
{
array = ko.unwrap(array);
array.push(data);
if (array.length > plot_size)
array.shift();
}
开发者ID:DavideCanton,项目名称:FlaskTaskManager,代码行数:8,代码来源:utils.ts
示例6: _default
// Return default value if the input value is empty or null
static _default (value, defaultValue) {
value = ko.unwrap(value);
if (typeof value === "function") {
return value;
}
if (typeof value === "string") {
return _utils.trim(value) === '' ? defaultValue : value;
}
return value == null || value.length == 0 ? defaultValue : value;
};
开发者ID:RichiCoder1,项目名称:knockout-fade,代码行数:11,代码来源:textFilter.ts
示例7: function
init: function (element, valueAccessor, allBindings, viewModel) {
var value = valueAccessor();
var message = ko.unwrap(value.message);
var click = value.click;
ko.applyBindingsToNode(element, {
click: function () {
if (confirm(message))
return click.apply(this, Array.prototype.slice.apply(arguments));
}
}, viewModel);
}
开发者ID:ocdsoft,项目名称:TypeScriptKnockoutSample,代码行数:11,代码来源:knockout-bindinghandlers.ts
示例8: function
bindingHandler.update = function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
beforeUpdate && beforeUpdate.apply(this, arguments);
const
data = ko.unwrap(valueAccessor()),
templateComputed = ko.renderTemplate(
data.template || bindingHandler.template,
bindingContext.createChildContext(data, name),
{},
element
);
disposeOldComputedAndStoreNewOne(element, templateComputed);
};
开发者ID:spatools,项目名称:koui,代码行数:15,代码来源:utils.ts
示例9:
const cpArray = ko.pureComputed(() => {
if (cpArray[OLD_VALUES_PROPERTY]) {
cpArray[OLD_VALUES_PROPERTY].forEach(d => {
if (typeof d.dispose === "function") {
d.dispose();
}
});
}
const val = ko.unwrap(value);
if (!Array.isArray(val)) {
cpArray[OLD_VALUES_PROPERTY] = null;
return [];
}
return cpArray[OLD_VALUES_PROPERTY] = val.map(mapFunction, context);
});
开发者ID:spatools,项目名称:koui,代码行数:17,代码来源:utils.ts
注:本文中的knockout.unwrap函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论