當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript knockout.unwrap函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。