當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。