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


TypeScript satcheljs.action函數代碼示例

本文整理匯總了TypeScript中satcheljs.action函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript action函數的具體用法?TypeScript action怎麽用?TypeScript action使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了action函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: updateItem

import { action } from 'satcheljs';
import Store from '../store/store';

let updateItem =
    function updateItem(id: string, text: string) {
        let items = Store.items.filter(item => item.id == id);
        if (items.length == 1) {
            let item = items[0];
            item.text = text;
        }
    };

export default action("updateItem")(updateItem);
開發者ID:Microsoft,項目名稱:satcheljs-todomvc,代碼行數:13,代碼來源:updateItem.ts

示例2: updateEditItemValue

import { action } from 'satcheljs';
import Store from '../store/store';

let updateEditItemValue =
    function updateEditItemValue(text: string) {
        Store.editItemText = text;
    };

export default action("updateEditItemValue")(updateEditItemValue);
開發者ID:Microsoft,項目名稱:satcheljs-todomvc,代碼行數:9,代碼來源:updateEditItemValue.ts

示例3: updateTextboxValue

import { action } from 'satcheljs';
import Store from '../store/store';

let updateTextboxValue =
    function updateTextboxValue(text: string) {
        Store.textboxValue = text;
    };

export default action("updateTextboxValue")(updateTextboxValue);
開發者ID:Microsoft,項目名稱:satcheljs-todomvc,代碼行數:9,代碼來源:updateTextboxValue.ts

示例4: toggleCompleted

import { action } from 'satcheljs';
import Store from '../store/store';

let toggleCompleted =
    function toggleCompleted(id: string) {
        let items = Store.items.filter(item => item.id == id);
        items[0].completed = !items[0].completed;

        Store.itemsLeft = Store.itemsLeft + (items[0].completed ? -1 : 1);
    };

export default action("toggleCompleted")(toggleCompleted);
開發者ID:Microsoft,項目名稱:satcheljs-todomvc,代碼行數:12,代碼來源:toggleCompleted.ts

示例5: toggleEditItem

import { action } from 'satcheljs';
import Store from '../store/store';

let toggleEditItem =
    function toggleEditItem(id: string) {
        if (Store.editItemId != id && id) {
            let items = Store.items.filter(item => item.id == id);
            Store.editItemId = id;
            Store.editItemText = items[0].text;
        } else {
            Store.editItemId = null;
        }
    };

export default action("toggleEditItem")(toggleEditItem);
開發者ID:Microsoft,項目名稱:satcheljs-todomvc,代碼行數:15,代碼來源:toggleEditItem.ts

示例6: removeAllCompleted

import { action } from 'satcheljs';
import Store from '../store/store';

let removeAllCompleted =
    function removeAllCompleted() {
        let index = 0;
        let items = Store.items;
        let numberOfSplicedItems = 0;

        if (items.length > 0) {
            let item = items[0];

            while (item != null) {
                if (item.completed) {
                    items.splice(index, 1);
                    numberOfSplicedItems++;
                } else {
                    index++;
                }

                item = items[index];
            }
        }
    };

export default action("removeAllCompleted")(removeAllCompleted);
開發者ID:Microsoft,項目名稱:satcheljs-todomvc,代碼行數:26,代碼來源:removeAllCompleted.ts


注:本文中的satcheljs.action函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。