Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bit-state-source

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bit-state-source

## 使用

  • 1.3.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

状态管理数据源

使用

import todoStore from 'bit-state-source';

const main = async () => {
    const todoItems = await todoStore.listItems();
    console.log(todoItems);
};

默认会随机生成若干个待办事项,每个待办事项的结构:

interface TodoItem {
    id: string;
    title: string;
    comment: string;
    dueDate: Date;
    completed: boolean;
}

可用的方法:

interface TodoListOptions {
    // 页码,从1开始
    pageIndex: number;
    // 每页条目数
    pageSize: number;
}

interface TodoListResult {
    totalCount: number;
    totalPageCount: number;
    items: TodoItem[];
}

interface TodoStore {
    // 获取事项列表,带分页
    listItems(options: TodoListOptions): Promise<TodoItem[]>;
    // 根据id找到待办开顺
    findItem(id: string): Promise<TodoItem>;
    // 新增一个事项,会填充id后返回
    saveItem(item: TodoItem): Promise<TodoItem>;
    // 更新一个事项,作为参数的item中必须有id字段
    updateItem(item: TodoItem): Promise<void>;
    // 删除一个事项
    deleteItem(id: string): Promise<void>;
}

FAQs

Package last updated on 22 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc