当前位置: 首页 > 软件库 > 程序开发 > 网络工具包 >

re-quests

Declarative networking for React.
授权协议 Readme
开发语言 C/C++
所属分类 程序开发、 网络工具包
软件类型 开源软件
地区 不详
投 递 者 鲁单弓
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

re-quests

Declarative Networking for React.

npmnpm

Quick Start

1. Install with NPM (or Yarn)

npm install --save re-quests

2. Fire up a network request by rendering the Request.

import Request from 're-quests';

...
render (
    <Request
        url='https://my-awesome-doma.in/me'
        onSuccess={this.myAwesomeResponseHandler}>
    
        <div> {/* use View for react-native */}
            <Request.Start>
                <MyAwesomeSpinner />
            </Request.Start>
            <Request.Success>
                <MyAwesomeContent content={this.state.content} />
            </Request.Success>
            <Request.Failure>
                <MyAwesomeErrorMessage />
            </Request.Failure>
        </div>
    </Request>
)

3. Handle the response the way you want.

myAwesomeResponseHandler = (response) => {
    // set a local state
    this.setState({
        content: response.data
    });
    
    // or dispatch an event
    // this.props.dispatch(myAwesomeAction(response.data));
}

Recipes

For common day problems & how to's, check out the Recipes page.

Disclosure

The library being used for sending requests is axios.Request component is just a declarative wrapper around it,exposing a few of the capabilities of axios.

Props

// `url` is the server URL that will be used for the request
url: PropTypes.string.isRequired,

// the http method is not required by axios &
// defaults to 'get' if not provided
method: PropTypes.oneOf(['get', 'post', 'put', 'patch', 'delete', 'head']),

// `headers` are custom headers to be sent
headers: PropTypes.object,

// `params` are the URL parameters to be sent with the request
// Must be a plain object or a URLSearchParams object
params: PropTypes.object,

// `data` is the data to be sent as the request body
// Only applicable for request methods 'PUT', 'POST', and 'PATCH'
// When no `transformRequest` is set, must be of one of the following types:
// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
// - Browser only: FormData, File, Blob
// - Node only: Stream
data: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.object,
    PropTypes.instanceOf(ArrayBuffer),
    PropTypes.instanceOf(ArrayBufferView),
    PropTypes.instanceOf(URLSearchParams)
]),

// `paramsSerializer` is an optional function in charge of serializing `params`
// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
// default: function(params) { return Qs.stringify(params, {arrayFormat: 'brackets'}) }
paramsSerializer: PropTypes.func,

// `transformRequest` allows changes to the request data before it is sent to the server
// This is only applicable for request methods 'PUT', 'POST', and 'PATCH'
// The last function in the array must return a string, an ArrayBuffer, FormData, or a Stream
transformRequest: PropTypes.arrayOf(PropTypes.func),

// `transformResponse` allows changes to the response data to be made before
// it is passed to then/catch
transformResponse: PropTypes.arrayOf(PropTypes.func),

// `validateStatus` defines whether to resolve or reject the promise for a given
// HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
// or `undefined`), the promise will be resolved; otherwise, the promise will be
// rejected.
// default: function (status) { return status >= 200 && status < 300; }
validateStatus: PropTypes.func,

// `maxRedirects` defines the maximum number of redirects to follow in node.js.
// If set to 0, no redirects will be followed.
// default: 5
maxRedirects: PropTypes.number,

// `timeout` specifies the number of milliseconds before the request times out.
// If the request takes longer than `timeout`, the request will be aborted.
timeout: PropTypes.number,

// `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
// This will set an `Authorization` header, overwriting any existing
// `Authorization` custom headers you have set using `headers`.
// { username: 'janedoe', password: 's00pers3cret' }
auth: PropTypes.shape({
    username: PropTypes.string,
    password: PropTypes.string
}),

// `responseType` indicates the type of data that the server will respond with
// options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'
// default: json
responseType: PropTypes.oneOf(['arraybuffer', 'blob', 'document', 'json', 'text', 'stream']),

// `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
// default: 'XSRF-TOKEN'
xsrfCookieName: PropTypes.string,

// `xsrfHeaderName` is the name of the http header that carries the xsrf token value
// default: 'X-XSRF-TOKEN'
xsrfHeaderName: PropTypes.string,


// callback fired just before the request is fired
onStart: PropTypes.func,

// callback fired after the response 
// comes back with status 2XX
onSuccess: PropTypes.func,

// callback fired after the response 
// comes back with status other 2XX
onFailure: PropTypes.func,

// callback fired when 
// something else goes wrong
onError: PropTypes.func,

// defer signals the Request component to not fire the 
// request as soon as ready instead construct the request and 
// wait for the manual trigger
// useful for cases when either the data is incomplete 
// or we want to wait for a CTA 
defer: PropTypes.bool,

// request can be tagged for enabling nested scenarios
// we might want to render a component based on 
// request sent way above the hierarchy of the component
// super grand parent component :P
tag: PropTypes.string

Limitations

Contribution

Any and all the contribution is welcome, providing it aligns with the interest of the project.Please make sure the commit messages follow the convention from the git commit template.

  • 传送门,肯定是没有的。 题解: 可以很显然地发现,只有当包含当前位置的询问集合不同的时候,我们能够区分这些位置。 定义一个不可识别子串 [ l , r ] [l,r] [l,r]为其左右位置无法区分的子串。 定义一个极长不可识别子串 [ l , r ] [l,r] [l,r]为一个不可识别子串,且不存在任何 l ′ ≤ l , r ′ ≥ r l&#x27;\leq l ,r&#x27;\geq

  • 传送门 考试的时候没读懂怎么才准确猜出 考虑 f [ i ] f[i] f[i]表示长度为 i i i全部分辨出来的方案数 直接不好求,考虑求出有区间分辨不出来的方案数 显然必定是连续的一段区间无法分辨 容斥的话就相当于有几个小区间 相互能分辨,自己内部无法分辨 考虑 g [ i ] [ j ] g[i][j] g[i][j]表示把 i i i个点分成 j j j段的方案数 可以直接枚举下一段的长

  • 【描述】 有一天,球球和他的好朋友熊熊在玩一个猜数字的游戏。 这个游戏是这样子的:熊熊会先在 [1, n] 中选取一个数,然后问球球他选取的数是多少。球球当然不知 道啦,所以他会向熊熊提出若干个问题,每个问题形如:选取的数是否在[li,ri]之间?球球可以提出很 多的问题,而熊熊也会不厌其烦地回答他。形式化地,对于球球给出的一个询问集合 Q,熊 熊会返回一 个长为 |Q| 的 01 序列表示每次询

 相关资料
  • re-pattern 返回java.util.regex.Pattern的实例。 然后将其用于进一步的模式匹配方法。 语法 (Syntax) 以下是语法。 (re-pattern pat) Parameters - 'pat'是需要形成的模式。 Return Value - java.util.regex.Pattern类型的模式对象。 例子 (Example) 以下是Clojure中重新模式的

  • Kiki 是一个基于 Python/wxPython 环境的正则表达式测试工具,通过输入正则表达式和要匹配的文本,Kiki 将高亮显示匹配到的字符串和匹配的数量。

  • re-graph re-graph is a graphql client for Clojure and ClojureScript with bindings for re-frame applications. Notes This library behaves like the popular Apollo clientfor graphql and as such is compati

  • re-start �� �� �� Aim of the project Target multiple platforms (Android, iOS, Web, Windows[UWP] and Electron[macOS,Linux, Windows]) with react native' APIs and a single codebase. Follow best practices

  • re-base 是基于 Relay 的构建 ReactJS 和 Firebase 应用的工具库,结合了 React 和 Firebase 的优势,允许每个组件指定自身的数据依赖,无需关注数据持久化,专注于应用的关键问题。 特性: syncState:组件状态和 Firebase 端点的双向数据绑定 bindToState:单向数据绑定 listenTo fetch post:添加新数据到 Fire

  • RE-Googl是一个ida pro反汇编交互式插件,它可以自动通过google查询二进制反汇编过程中包含的函数相关信息。排在前面的结果将会以注释的方式显示,显示的信息是一个链接,双击可以打开。RE-Googl首先需要IDA,然后需要 IDAPython,最后需要安装Google Data APIs for Python。