mesosphere-shared-reactjs
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -174,2 +174,9 @@ var StringUtil = require('../utils/StringUtil'); | ||
if (listenerDetail.suppressUpdate !== true && typeof this.forceUpdate === 'function') { | ||
if (process.env.NODE_ENV === 'performance') { | ||
var warning = 'Forced upates are an antipattern. '; | ||
if (this.saveState_key != null) { | ||
warning += 'Check the render method of ' + this.saveState_key + '.'; | ||
} | ||
console.warn(warning); | ||
} | ||
this.forceUpdate(); | ||
@@ -176,0 +183,0 @@ } |
{ | ||
"name": "mesosphere-shared-reactjs", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "Shared code from mesosphere web projects", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,2 +8,20 @@ var Reqwest = require("./Reqwest"); | ||
function createRequestID(request) { | ||
var contentType = request.contentType || ''; | ||
var data = ''; | ||
var headers = ''; | ||
var method = request.method || ''; | ||
var url = request.url || ''; | ||
if (request.data != null) { | ||
data = JSON.stringify(request.data); | ||
} | ||
if (request.headers != null) { | ||
headers = JSON.stringify(request.headers); | ||
} | ||
return method + ':' + url + ':' + data + ':' + contentType + ':' + headers; | ||
} | ||
function createCallbackWrapper(callback, requestID) { | ||
@@ -77,16 +95,19 @@ return function () { | ||
options || (options = {}); | ||
var requestID = createRequestID(options); | ||
var usingHangingRequest = Util.isFunction(options.hangingRequestCallback); | ||
if (usingHangingRequest) { | ||
var requestID = options.url; | ||
options.success = createCallbackWrapper(options.success, requestID); | ||
options.error = createCallbackWrapper(options.error, requestID); | ||
// The proxied success and error methods mark the request as inactive when | ||
// the request resolves. | ||
options.success = createCallbackWrapper(options.success, requestID); | ||
options.error = createCallbackWrapper(options.error, requestID); | ||
if (isRequestActive(requestID)) { | ||
// If request is currently active, we don't make another request. | ||
if (isRequestActive(requestID)) { | ||
if (Util.isFunction(options.hangingRequestCallback)) { | ||
options.hangingRequestCallback(); | ||
return; | ||
} else { | ||
setRequestState(requestID, true); | ||
delete options.hangingRequestCallback; | ||
} | ||
return; | ||
} else { | ||
setRequestState(requestID, true); | ||
delete options.hangingRequestCallback; | ||
} | ||
@@ -106,12 +127,5 @@ | ||
// Only add timeout if it is not using hanging request | ||
var timeout; | ||
if (!usingHangingRequest) { | ||
timeout = 2000; | ||
} | ||
options = Util.extend({}, { | ||
contentType: "application/json; charset=utf-8", | ||
type: "json", | ||
timeout: timeout, | ||
method: "GET" | ||
@@ -118,0 +132,0 @@ }, options); |
51978
16
1072
2