当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript IItemsHoldr.setItem方法代码示例

本文整理汇总了TypeScript中IItemsHoldr.IItemsHoldr.setItem方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IItemsHoldr.setItem方法的具体用法?TypeScript IItemsHoldr.setItem怎么用?TypeScript IItemsHoldr.setItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IItemsHoldr.IItemsHoldr的用法示例。


在下文中一共展示了IItemsHoldr.setItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: ensureCollectionKeyExists

    /**
     * Ensures a collection exists by checking for it and creating it under
     * the internal ItemsHoldr if it doesn't.
     * 
     * @param collectionKey   The key for the collection that must exist,
     *                        including the prefix.
     */
    private ensureCollectionKeyExists(collectionKey: string): void {
        if (!this.ItemsHolder.hasKey(collectionKey)) {
            this.ItemsHolder.addItem(collectionKey, {
                "valueDefault": {},
                "storeLocally": true
            });

            this.collectionKeys.push(collectionKey);
            this.ItemsHolder.setItem(this.prefix + "collectionKeys", this.collectionKeys);
        }
    }
开发者ID:gpnoel,项目名称:StateHoldr,代码行数:18,代码来源:StateHoldr.ts

示例2: setCollection

    /**
     * Sets the currently tracked collection.
     * 
     * @param collectionKeyRawNew   The raw key of the new collection
     *                              to switch to.
     * @param value   An optional container of values to set the new
     *                collection equal to.
     */
    public setCollection(collectionKeyRawNew: string, value?: any): void {
        this.collectionKeyRaw = collectionKeyRawNew;
        this.collectionKey = this.prefix + this.collectionKeyRaw;

        this.ensureCollectionKeyExists(this.collectionKey);

        if (value) {
            this.ItemsHolder.setItem(this.collectionKey, value);
        }

        this.collection = this.ItemsHolder.getItem(this.collectionKey);
    }
开发者ID:gpnoel,项目名称:StateHoldr,代码行数:20,代码来源:StateHoldr.ts

示例3: addCollectionChange

    /**
     * Adds a change to any collection requested by the key, stored as a key-value
     * pair under an item.
     * 
     * @param collectionKeyOtherRaw   The raw key for the other collection
     *                                to add the change under.
     * @param itemKey   The key for the item experiencing the change.
     * @param valueKey   The attribute of the item being changed.
     * @param value   The actual value being stored.
     */
    public addCollectionChange(collectionKeyOtherRaw: string, itemKey: string, valueKey: string, value: any): void {
        const collectionKeyOther: string = this.prefix + collectionKeyOtherRaw;

        this.ensureCollectionKeyExists(collectionKeyOther);
        const otherCollection: any = this.ItemsHolder.getItem(collectionKeyOther);

        if (typeof otherCollection[itemKey] === "undefined") {
            otherCollection[itemKey] = {};
        }

        otherCollection[itemKey][valueKey] = value;

        this.ItemsHolder.setItem(collectionKeyOther, otherCollection);
    }
开发者ID:gpnoel,项目名称:StateHoldr,代码行数:24,代码来源:StateHoldr.ts

示例4: saveCollection

 /**
  * Saves the currently tracked collection into the ItemsHolder.
  */
 public saveCollection(): void {
     this.ItemsHolder.setItem(this.collectionKey, this.collection);
     this.ItemsHolder.setItem(this.prefix + "collectionKeys", this.collectionKeys);
 }
开发者ID:gpnoel,项目名称:StateHoldr,代码行数:7,代码来源:StateHoldr.ts


注:本文中的IItemsHoldr.IItemsHoldr.setItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。