@aantron/repromise 中文文档教程

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

Repromise    Version 0.6.1Travis status

Repromise 是对 JS promises 的绑定,具有:

  • Interop — each Repromise is a JS promise, so JS libraries that return promises already return Repromises, and existing JS tooling should work.
  • Type safety — Repromises nest, and don't "collapse" like JS promises.
  • Explicit errors — no baked-in reject or exception handling, so you can choose how to handle errors.
  • Minimal code — the compiled repromise.js compresses to about 1K.
  • Native support — Repromise also has a pure-Reason implementation, which compiles to native code.


let (p, resolve_p) = Repromise.make();

p
|> Repromise.map(s => s ++ ", world!")
|> Repromise.wait(print_endline);

resolve_p("Hello");

/* Prints "Hello, world!" */


Installing

npm install bs-platform
npm install @aantron/repromise

添加 @aantron/repromise 到你的 bsconfig.json

{
  "bs-dependencies": [
    "@aantron/repromise"
  ]
}

>

Sample projects

:展示如何依赖 Repromise 并开始使用它:


Docs

......在线

首先,我们建议您查看“Hello, world!” 项目 ,然后阅读 API 文档。 从wait开始,每个函数都有示例。 您可以将它们粘贴到 “Hello, world!” 项目中以使用 Repromise。

设计常见问题提供了有关 Repromise 的一些背景知识。

要学习如何编写绑定,我们建议从 node-fetch 项目开始,然后阅读 Interop 文档,也许还有 可拒绝的 API 文档


Roadmap


Contact

请不要犹豫打开一个问题,或者来在 Discord 上打扰我们。 欢迎所有问题、反馈和bikeshedding :)

Repromise 处于早期开发阶段,我们可以改变一切。

Repromise    Version 0.6.1Travis status

Repromise is a binding to JS promises, with:

  • Interop — each Repromise is a JS promise, so JS libraries that return promises already return Repromises, and existing JS tooling should work.
  • Type safety — Repromises nest, and don't "collapse" like JS promises.
  • Explicit errors — no baked-in reject or exception handling, so you can choose how to handle errors.
  • Minimal code — the compiled repromise.js compresses to about 1K.
  • Native support — Repromise also has a pure-Reason implementation, which compiles to native code.


let (p, resolve_p) = Repromise.make();

p
|> Repromise.map(s => s ++ ", world!")
|> Repromise.wait(print_endline);

resolve_p("Hello");

/* Prints "Hello, world!" */


Installing

npm install bs-platform
npm install @aantron/repromise

Add @aantron/repromise to your bsconfig.json:

{
  "bs-dependencies": [
    "@aantron/repromise"
  ]
}


Sample projects

We have a couple repos that show how to depend on Repromise and get started with it:


Docs

…are online!

To begin, we recommend looking at the "Hello, world!" project, and then reading the API docs. Starting from wait, each function has examples. You can paste them into the "Hello, world!" project to play around with Repromise.

The Design FAQ gives some background about Repromise.

To learn how to write bindings, we suggest starting with the node-fetch project, then reading the Interop docs, and perhaps the rejectable API docs.


Roadmap


Contact

Please don't hesitate to open an issue, or come bug us on Discord. All questions, feedback, and bikeshedding are welcome :)

Repromise is at a pretty early stage of development, and we can change just about everything.

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