本文整理汇总了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);
示例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);
示例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);
示例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);
示例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);
示例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);