Comparing version 0.3.0 to 1.0.0
@@ -6,3 +6,2 @@ 'use strict'; | ||
}); | ||
exports.jax = exports.jaxDefaults = undefined; | ||
@@ -29,4 +28,2 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -38,25 +35,14 @@ | ||
// overrideable defaults for the package | ||
var jaxDefaults = exports.jaxDefaults = { | ||
client: null, | ||
methods: ['get', 'post', 'del', 'put'], | ||
pendingKey: 'pending', | ||
abortKey: 'abort', | ||
endEvents: ['end', 'abort', 'error'] | ||
}; | ||
exports.default = function () { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
client = _ref.client, | ||
_ref$endEvents = _ref.endEvents, | ||
endEvents = _ref$endEvents === undefined ? ['end', 'abort', 'error'] : _ref$endEvents, | ||
_ref$methods = _ref.methods, | ||
methods = _ref$methods === undefined ? ['get', 'post', 'del', 'put'] : _ref$methods, | ||
_ref$abortKey = _ref.abortKey, | ||
abortKey = _ref$abortKey === undefined ? 'abort' : _ref$abortKey, | ||
_ref$pendingKey = _ref.pendingKey, | ||
pendingKey = _ref$pendingKey === undefined ? 'pending' : _ref$pendingKey; | ||
// the decorator | ||
var jax = exports.jax = function jax() { | ||
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var _ref$client = _ref.client; | ||
var client = _ref$client === undefined ? jaxDefaults.client : _ref$client; | ||
var _ref$methods = _ref.methods; | ||
var methods = _ref$methods === undefined ? jaxDefaults.methods : _ref$methods; | ||
var _ref$abortKey = _ref.abortKey; | ||
var abortKey = _ref$abortKey === undefined ? jaxDefaults.abortKey : _ref$abortKey; | ||
var _ref$pendingKey = _ref.pendingKey; | ||
var pendingKey = _ref$pendingKey === undefined ? jaxDefaults.pendingKey : _ref$pendingKey; | ||
var _ref$endEvents = _ref.endEvents; | ||
var endEvents = _ref$endEvents === undefined ? jaxDefaults.endEvents : _ref$endEvents; | ||
return function (OriginalComponent) { | ||
@@ -157,5 +143,6 @@ if (!OriginalComponent) throw new Error('No component to wrap.'); | ||
value: function render() { | ||
var _extends2; | ||
var props = _extends({}, this.props, this.methods); | ||
var props = _extends({}, this.props, this.methods, (_extends2 = {}, _defineProperty(_extends2, abortKey, this.abort), _defineProperty(_extends2, pendingKey, this.state.pending), _extends2)); | ||
if (abortKey) props[abortKey] = this.abort; | ||
if (pendingKey) props[pendingKey] = this.state.pending; | ||
@@ -162,0 +149,0 @@ return (0, _react.createElement)(OriginalComponent, props); |
{ | ||
"name": "react-jax", | ||
"version": "0.3.0", | ||
"version": "1.0.0", | ||
"description": "A tiny decorator to manage AJAX requests in React components.", | ||
@@ -32,3 +32,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"hoist-non-react-statics": "^1.2.0", | ||
"hoist-non-react-statics": "^2.0.0", | ||
"lodash": "^4.15.0", | ||
@@ -51,8 +51,9 @@ "react-display-name": "^0.2.0" | ||
"mocha": "^2.3.4", | ||
"react": "^0.14.7", | ||
"react-addons-test-utils": "^0.14.7", | ||
"react": "^15.6.1", | ||
"react-addons-test-utils": "^15.6.0", | ||
"react-dom": "^15.6.1", | ||
"sinon": "^1.17.5", | ||
"sinon-chai": "^2.8.0", | ||
"superagent": "^1.8.0" | ||
"superagent": "^3.5.2" | ||
} | ||
} |
@@ -14,11 +14,7 @@ # react-jax [![Build Status](https://travis-ci.org/azuqua/react-jax.svg?branch=master)](https://travis-ci.org/azuqua/react-jax) | ||
import React from 'react'; | ||
import { jax, jaxDefaults } from 'react-jax'; | ||
import jax from 'react-jax'; | ||
import superagent from 'superagent'; | ||
/* set global defaults */ | ||
jaxDefaults.client = superagent; // IMPORTANT | ||
jaxDefaults.pendingKey = 'loading'; | ||
/* overwrite global options for a specific component */ | ||
@jax({ // same as defaults | ||
@jax({ | ||
client: superagent, // only required option | ||
methods: ['get', 'post', 'del', 'put'], | ||
@@ -65,4 +61,3 @@ pendingKey: 'pending', | ||
These options can be passed to the `jax()` function. Or be set on the | ||
exported `jaxDefaults` object. | ||
These options are passed to the `jax()` function. | ||
@@ -80,3 +75,3 @@ ##### `client` __required__ | ||
#### `endEvents` defaults to `['end', 'abort']` | ||
#### `endEvents` defaults to `['end', 'abort', 'error']` | ||
Events emitted by the clients request object than indicate it should be | ||
@@ -83,0 +78,0 @@ cleaned up. |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
12839
19
129
88
+ Addedhoist-non-react-statics@2.5.5(transitive)
- Removedhoist-non-react-statics@1.2.0(transitive)