@21epub/epub-data-client 中文文档教程

发布于 3年前 浏览 26 项目主页 更新于 3年前

@21epub/epub-data-client

epub 的数据 api 客户端

NPMJavaScript 风格指南Build Status Codecov

Intro

嗯,这是一个数据客户端电子版 (可改成其他用法)

Feature

  • [x] Easy-to-use
  • [x] Typescript Only
  • [x] RestFul data client support
  • [x] Object Client support
  • [x] Local data manupulate
  • [x] Hooks for data client
  • [x] Both for web and node supported
  • [x] Uniform the error catch for both http error and response code error

Install

npm install --save @21epub/epub-data-client

Usage

import { DataClient } from '@21epub/epub-data-client'

const client = new DataClient('http://url.to/data/')

client.getAll()

class Example extends Component {
  data = client.useData()
  render() {
    return (
      <>
        <div> Total Data: {data?.length} </div>
      </>
    )
  }
}

详情见示例

Developing and running on localhost

先安装依赖,再安装peerDeps for parcel dev:

npm install
npm run install-peers

热模块重载模式下运行示例:

npm start

创建parcel示例生产构建:

npm run build-prod

创建bundle库模块构建

npm run build

:更新文档

npm run doc

Running

在浏览器中打开文件 dist/index.html

Testing

要运行单元测试:

npm test

License

MIT © 21epub

@21epub/epub-data-client

data api client for epub

NPMJavaScript Style GuideBuild Status Codecov

Intro

Well, This is a data client for Epub . ( Can be reformed for other Usage )

Feature

  • [x] Easy-to-use
  • [x] Typescript Only
  • [x] RestFul data client support
  • [x] Object Client support
  • [x] Local data manupulate
  • [x] Hooks for data client
  • [x] Both for web and node supported
  • [x] Uniform the error catch for both http error and response code error

Install

npm install --save @21epub/epub-data-client

Usage

import { DataClient } from '@21epub/epub-data-client'

const client = new DataClient('http://url.to/data/')

client.getAll()

class Example extends Component {
  data = client.useData()
  render() {
    return (
      <>
        <div> Total Data: {data?.length} </div>
      </>
    )
  }
}

For Details: See Example

Developing and running on localhost

First install dependencies and then install peerDeps for parcel dev:

npm install
npm run install-peers

To run Example in hot module reloading mode:

npm start

To create a parcel example production build:

npm run build-prod

To create a bundle library module build:

npm run build

To update documentation

npm run doc

Running

Open the file dist/index.html in your browser

Testing

To run unit tests:

npm test

License

MIT © 21epub

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文