react-backend
Advanced tools
+1
-3
@@ -123,2 +123,3 @@ 'use strict'; | ||
| // we store all the promises in the resolvers array | ||
| // in such a way that they will always resolve (never reject) | ||
| var resolvers = []; | ||
@@ -167,5 +168,2 @@ Object.values(this.promises).forEach(function (promise) { | ||
| self._shouldReload = false; | ||
| }, function (error) { | ||
| self._shouldReload = false; | ||
| return Promise.reject(error); | ||
| }); | ||
@@ -172,0 +170,0 @@ } |
+1
-1
| { | ||
| "name": "react-backend", | ||
| "version": "1.0.9", | ||
| "version": "1.1.1", | ||
| "description": "A framework which help fetch data from backends and provide them to React.js components.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+2
-2
@@ -32,3 +32,3 @@ # react-backend | ||
| To test it, first clone the [Git repository](https://github.com/Hextrakt/react-backend). Then, run | ||
| To test it, first clone the Git repository of [react-backend](https://github.com/Hextrakt/react-backend). Then, run | ||
@@ -108,3 +108,3 @@ ```js | ||
| getUserInfo() { | ||
| return when("getUserId").then(id => return database.loadUserInfo(id)) | ||
| return when("getUserId").then(id => database.loadUserInfo(id)) | ||
| } | ||
@@ -111,0 +111,0 @@ getUserId() { |
@@ -82,2 +82,3 @@ /** | ||
| // we store all the promises in the resolvers array | ||
| // in such a way that they will always resolve (never reject) | ||
| let resolvers = [] | ||
@@ -105,6 +106,2 @@ Object.values(this.promises).forEach(promise => { | ||
| self._shouldReload = false | ||
| }, | ||
| function(error) { | ||
| self._shouldReload = false | ||
| return Promise.reject(error) | ||
| } | ||
@@ -111,0 +108,0 @@ ) |
| { | ||
| "name": "react-backend-samples", | ||
| "version": "1.0.9", | ||
| "version": "1.1.1", | ||
| "description": "Samples for react-backend", | ||
@@ -20,3 +20,3 @@ "main": "index.js", | ||
| "react": "^16.2.0", | ||
| "react-backend": "^1.0.9", | ||
| "react-backend": "^1.1.1", | ||
| "react-dom": "^16.2.0", | ||
@@ -23,0 +23,0 @@ "react-helmet": "^5.2.0", |
@@ -24,2 +24,3 @@ import React, { Fragment } from 'react' | ||
| dataProvider.need1 = spy(() => Promise.resolve("need1")) | ||
| dataProvider.need2Failed = spy(() => Promise.reject("need2Failed")) | ||
| spy(dataProvider, 'getData') | ||
@@ -29,3 +30,4 @@ spy(dataProvider, 'resolveNeeds') | ||
| renderPresentation = ({dataProvider}) => ( | ||
| <span>Need1 is {dataProvider.getData('need1')}</span>) | ||
| <div><span>Need1 is {dataProvider.getData('need1')}</span> | ||
| <span>Need2 is {dataProvider.getError('need2Failed')}</span></div>) | ||
| renderPresentation = spy(renderPresentation) | ||
@@ -39,2 +41,3 @@ const Presentation = withDataProvider(renderPresentation) | ||
| <NeedsData needs="need1"/> | ||
| <NeedsData needs="need2Failed"/> | ||
| </ProviderRules> | ||
@@ -56,2 +59,3 @@ <WithData dataProvider={dataProvider}> | ||
| test.bool(dataProvider.need1.calledOnce).isTrue() | ||
| test.bool(dataProvider.need2Failed.calledOnce).isTrue() | ||
| done() | ||
@@ -79,2 +83,3 @@ }).catch(function() { | ||
| .string(markup).contains('need1') | ||
| .string(markup).contains('need2Failed') | ||
| done() | ||
@@ -86,2 +91,12 @@ }).catch(function() { | ||
| it('will provide errors', function(done) { | ||
| render.render().then(function(markup) { | ||
| test | ||
| .bool(dataProvider.hasErrors()).isTrue() | ||
| .string(markup).contains('need2Failed') | ||
| done() | ||
| }).catch(function() { | ||
| test.undefined("Test should not come here") | ||
| }) | ||
| }) | ||
| }) |
@@ -87,3 +87,3 @@ import test from 'unit.js' | ||
| }) | ||
| }) |
+1
-2
@@ -67,4 +67,3 @@ 'use strict'; | ||
| /** | ||
| * When there is 'reload' in the query string, | ||
| * this component will wait until all the data from the backend are ready (or in error) | ||
| * This component will wait until all the data from the backend are ready (or in error) | ||
| * and then will update the component tree. | ||
@@ -71,0 +70,0 @@ * @returns {Boolean} |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
343797
0.14%1755
0.52%