Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
626ff26
Fix lint warning
ericclemmons Apr 13, 2015
a9ca6ef
Add tests for explicit values of props & context
ericclemmons Apr 14, 2015
dd36117
Lint src + test
ericclemmons Apr 14, 2015
e8e4d11
Add subpage to show context usage
ericclemmons Apr 14, 2015
af73548
Add Contexts to Upcoming...
ericclemmons Apr 14, 2015
8f1d0dc
Merge pull request #21 from ericclemmons/21-contexts
ericclemmons Apr 14, 2015
46d9e3b
Release v1.1.0
ericclemmons Apr 14, 2015
6c6fb03
Ignore more cruft
ericclemmons Apr 14, 2015
38b4a3f
Bump to v1.1.1
ericclemmons Apr 14, 2015
e01bd3c
Remove devDependencies warning
ericclemmons Apr 14, 2015
dfaff49
Fixed missing braces to import Resolver
srph Apr 14, 2015
5a4da03
Merge pull request #24 from srph/patch-1
ericclemmons Apr 14, 2015
db21b22
Fix Resolver reference
ericclemmons Apr 14, 2015
9e4276a
Backup Resolver.js
ericclemmons Apr 15, 2015
ecbf4fc
Move back to Resolver.js
ericclemmons Apr 15, 2015
a513bbf
Bump to v1.1.2
ericclemmons Apr 15, 2015
8cd5e23
Backup resolver.js
ericclemmons Apr 15, 2015
2161d85
Rename resolver.js -> Resolver.js
ericclemmons Apr 15, 2015
3854f4d
Bump to v1.1.3
ericclemmons Apr 15, 2015
669a160
Remove legacy code from dist/
ericclemmons Apr 15, 2015
55cfda6
Fix spelling + grammar in README.md
frederickfogerty Apr 16, 2015
ca5a8c9
Merge pull request #30 from frederickfogerty/patch-1
ericclemmons Apr 16, 2015
a134120
require react/lib/cloneWithProps directly instead of through addons
iamdustan Apr 20, 2015
224a39e
Update Upcoming...
ericclemmons Apr 25, 2015
97fcccc
Merge branch 'master' of github.com:ericclemmons/react-resolver
ericclemmons Apr 25, 2015
8c69579
Add link to Upcoming
ericclemmons Apr 25, 2015
8e6a74c
Merge pull request #32 from iamdustan/react-clone-with-props
ericclemmons Apr 25, 2015
e6c6c24
1.1.4
ericclemmons Apr 25, 2015
9240087
Forgot to update build
ericclemmons Apr 25, 2015
6ec889b
1.1.5
ericclemmons Apr 25, 2015
fbc8c5e
WS
ericclemmons Apr 25, 2015
882a415
Name links to home
ericclemmons Apr 25, 2015
5db7c30
Check truthy value of this.states[id] vs. hasOwnProperty
ericclemmons Apr 25, 2015
8e34843
Remove unused {...this.props} reference
ericclemmons Apr 25, 2015
e0ad72a
Test for IDs of containers
ericclemmons Apr 25, 2015
95e5b3d
Add <Container /> lifecycle tests
ericclemmons Apr 25, 2015
787653e
Add resolver#clearContainerState
ericclemmons Apr 25, 2015
7697022
componentWillMount, componentWillUnmount, & componentWillReceiveProps
ericclemmons Apr 25, 2015
fd91f71
Update build
ericclemmons Apr 25, 2015
4154749
Move Follow from Nav to Stargazers
ericclemmons Apr 26, 2015
f7c0c83
Merge pull request #33 from ericclemmons/33-flush-cache
ericclemmons Apr 26, 2015
7e8848e
Update dependencies
ericclemmons Apr 26, 2015
acbef13
1.1.6
ericclemmons Apr 26, 2015
ed319c5
#29 was fixed in v1.1.6
ericclemmons Apr 26, 2015
f372e64
Add failing test
ericclemmons Apr 26, 2015
30c9faf
Remove unushed variable
ericclemmons Apr 26, 2015
d4cc91e
Delete all states starting with container ID
ericclemmons Apr 26, 2015
ec97fcd
WS
ericclemmons Apr 26, 2015
cf26be3
Update example
ericclemmons Apr 26, 2015
4397572
Add #37 to Upcoming
ericclemmons Apr 26, 2015
09aa583
Merge pull request #37 from ericclemmons/37-clear-nested-states
ericclemmons Apr 26, 2015
a3a3cc8
Context (#29) is still a bug
ericclemmons Apr 26, 2015
e039c24
1.1.7
ericclemmons Apr 26, 2015
132e5e1
Remove unecessary/unused reference to childContextTypes
ericclemmons Apr 26, 2015
7c9d666
WIP: Expose resolved state values
iamdustan Apr 21, 2015
60695e7
revert tests, still pass. There is a subtle API difference, though
iamdustan Apr 22, 2015
51e6ff0
rehydrate data on the client
iamdustan Apr 22, 2015
837f190
Rehydrate based on resolution keys
iamdustan Apr 22, 2015
bf3f8b7
Lint everything except the dangling underscores for __resolver__
iamdustan Apr 27, 2015
4d81384
Update stargazers README
ericclemmons May 12, 2015
2d985e4
Install react-resolver on install, not preinstall
ericclemmons May 12, 2015
0aa36af
Update build
ericclemmons May 12, 2015
b76adea
fixed rendertostring hanging on the serer with nested components
gilesbradshaw May 31, 2015
0766c4f
commented out redundant promise
gilesbradshaw May 31, 2015
b20c849
Merge https://github.com/ericclemmons/react-resolver into expose-clie…
gilesbradshaw May 31, 2015
9778460
starting to be csp
gilesbradshaw Jun 1, 2015
98835e1
finish returns a channel;
gilesbradshaw Jun 2, 2015
aaa09fe
You can push Error objects onto a channel however I'd like to change …
gilesbradshaw Jun 2, 2015
9e27277
Container will optionally errorRender and waitRender
gilesbradshaw Jun 2, 2015
b8cfab2
channels can now give more than one result
gilesbradshaw Jun 4, 2015
a3a92a0
Tests are passing on source code
gilesbradshaw Jun 5, 2015
b6d0570
nested test
gilesbradshaw Jun 6, 2015
9614d93
dom tests
gilesbradshaw Jun 6, 2015
9664980
Channels can be closed
gilesbradshaw Jun 6, 2015
3413f89
no var or let in resolver
gilesbradshaw Jun 6, 2015
7625639
tests changed to use dist
gilesbradshaw Jun 7, 2015
ab5ea89
updated read me
gilesbradshaw Jun 7, 2015
0f89cb4
updated travis badge
gilesbradshaw Jun 7, 2015
6d8b61f
updated travis badge with the right branch
gilesbradshaw Jun 7, 2015
6f32acb
renamed repository &c
gilesbradshaw Jun 7, 2015
4580fbd
update badge
gilesbradshaw Jun 7, 2015
d70dfad
got rid of failing test
gilesbradshaw Jun 7, 2015
44a5e95
fixed up package.json
gilesbradshaw Jun 7, 2015
42f1488
v0.0.2 exports decoratprs and CSP
gilesbradshaw Jun 7, 2015
70644b3
Added coeralls badge
gilesbradshaw Jun 7, 2015
d3af5a9
renamed js-csp package.json
gilesbradshaw Jun 7, 2015
be261b5
add src to npm
gilesbradshaw Jun 7, 2015
3e027f6
better attrib
gilesbradshaw Jun 7, 2015
f439b5b
better attrib..
gilesbradshaw Jun 7, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.eslintrc
.travis.yml
CHANGELOG.md
demo.png
examples
LICENSE
README.md
test
66 changes: 7 additions & 59 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,15 @@
# React Resolver Changelog
# React Resolver Csp Changelog

### Upcoming...
### v0.0.3 (2015-06-07)

- [Error Handling](https://github.com/ericclemmons/react-resolver/issues/2)
- [React Native](https://github.com/ericclemmons/react-resolver/issues/18)
- renamed js-csp so (hopefully) the whole lot will get published to npm

### v0.0.2 (2015-06-07)

### v1.0.0 - (2015-04-13)
- Includes decorators & exports csp

- Complete rewrite for React v0.13
- "Higher-order Components" via `Resolver.createContainer`
- Remove all dependencies (!)
+ [#9](https://github.com/ericclemmons/react-resolver/issues/9)
+ [#14](https://github.com/ericclemmons/react-resolver/issues/14)
+ [#15](https://github.com/ericclemmons/react-resolver/issues/15)

### v0.0.1 (2015-06-06)

### v0.2.0 - (2015-02-25)
- Initial version

- Remove [`resolver.handle`][11]


### v0.1.2 (2015-02-25)

- Fix [examples/contacts](https://github.com/ericclemmons/react-resolver/tree/e026a3b1cbf16995c10c825c18d2f20b6277f62f/examples/contacts)


### v0.1.1 (2015-02-25)

- Move `react-router` from `optionalDependencies` to `peerDependencies`


### v0.1.0 (2015-02-24)

- [#7][7] - Add `react` and `react-router` as `peerDependencies`.
- [#8][8] - Support React v0.13


### v0.0.4 (2015-02-24)

- [#4][4] - NPM package is ES5, not ES6.
- [#5][5] - Clarify use of `Resolver.mixin`.
- [#6][6] - README comparison to Relay.


### v0.0.3 (2015-02-19)

- Public release


### v0.0.2 (2015-02-18)

- Working prototype with context


### v0.0.1 (2015-01-29)

- Initial commit


[4]: https://github.com/ericclemmons/react-resolver/pull/4
[5]: https://github.com/ericclemmons/react-resolver/issues/5
[6]: https://github.com/ericclemmons/react-resolver/issues/6
[7]: https://github.com/ericclemmons/react-resolver/issues/7
[8]: https://github.com/ericclemmons/react-resolver/issues/8
[11]: https://github.com/ericclemmons/react-resolver/issues/11
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ Internet Systems Consortium license
===================================

Copyright (c) 2015 Eric Clemmons
Copyright (c) 2015 Giles Bradshaw

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
with or without fee is hereby granted, provided that the above copyright notices
and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
Expand Down
16 changes: 16 additions & 0 deletions Original LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Internet Systems Consortium license
===================================

Copyright (c) 2015 Eric Clemmons

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
227 changes: 80 additions & 147 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,136 +1,85 @@
# React Resolver ![https://img.shields.io/npm/v/react-resolver.svg](https://img.shields.io/npm/v/react-resolver.svg?style=flat-square)

> Isomorphic library to lazy-load data for React components

[![](https://img.shields.io/github/issues-raw/ericclemmons/react-resolver.svg?style=flat-square)](https://github.com/ericclemmons/react-resolver/issues)
[![](https://img.shields.io/travis/ericclemmons/react-resolver/master.svg?style=flat-square)](https://travis-ci.org/ericclemmons/react-resolver)
[![](https://img.shields.io/david/ericclemmons/react-resolver.svg?style=flat-square)](https://david-dm.org/ericclemmons/react-resolver#info=dependencies)
[![](https://img.shields.io/david/dev/ericclemmons/react-resolver.svg?style=flat-square)](https://david-dm.org/ericclemmons/react-resolver#info=devDependencies)


## Features

- **Promise-based** – Define & lazy-load component data dependencies and inject them as `props`.
- **Isomorphic** – Express/Koa/Hapi-friendly server-side rendering & progressive, client-side rendering.
- **Test friendly** – Containers promote separation between data-fetching & rendering.


## Demo

> [![Demo](demo.png)][demo]

[View Demo][demo]


- - -


- [Features](#features)
- [Demo](#demo)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
+ [Client](#client)
+ [Server](#server)
- [Changelog][changelog]
- [Development](#development)
- [Authors](#authors)
- [License][license]

- - -


## Requirements

- React `v0.13.x`

_For browsers that don't nativeuly support promises, use [ES6 Promise](https://github.com/jakearchibald/es6-promise)._


## Installation

```shell
npm install --save react-resolver
```

- - -

## Usage

_Example is based on [Stargazers.js](https://github.com/ericclemmons/react-resolver/blob/master/examples/stargazers/components/Stargazers.js) in the [demo][demo]._

Suppose you want to display list of users, but that data is loaded
asynchronously via an API.

Rather than having your component handle data-fetching _and_ rendering,
you can create a "container" that fetches the data and only renders when ready:

```javascript
import React from "react";
import { Resolver } from "react-resolver";

class Users extends React.Component {
render() {
return (
<ul>
{this.props.users.map(user => (
<li>{user}</li>
))}
</ul>
);
}
}

Users.defaultProps = { limit: 5 };
Users.propTypes = { users: React.PropTypes.array.isRequired };

// Rather than `export default Users`, create a container:
export default Resolver.createContainer(Users, {
resolve: {
users: function(props) {
return fetch(`/api/users?limit=${props.limit}`);
}
}
# React Resolver Csp

[![Build Status](https://travis-ci.org/gilesbradshaw/react-resolver-csp.svg?branch=csp)](https://travis-ci.org/gilesbradshaw/react-resolver-csp)

[![Coverage Status](https://coveralls.io/repos/gilesbradshaw/react-resolver-csp/badge.svg?branch=csp)](https://coveralls.io/r/gilesbradshaw/react-resolver-csp)

## Isomorphic library to lazy-load data for React components

Forked and nodified to use CSP channels rather than promises

I've manually included js-csp so the whole lot gets transpiled to ES5

````
describe("Resolver", function() {
describe(".nested", function() {
it("should render nested elements", function(done) {
@dataDependencies({
user: ()=>
go(function* (){
return "Ernie";
})
})
@displayName("TestElement1")
class Element1 extends Component {
render(){
return <span>{this.props.user}</span>;
}
};

@dataDependencies({
user: ()=>
go(function* (){
return "Eric";
})
})
@displayName("TestElement")
class Element extends Component {
render(){
return <span>{this.props.user}<Element1/></span>;
}
};
go(function*(){
const string = yield Resolver.renderToStaticMarkup(<Element />);
assert.equal("<span>Eric<span>Ernie</span></span>",string.toString());
done();
});
});
});
});

```


### Client

Replace `React.render` with `Resolver.render`, and you're all set!

```javascript
import React from "react";
import Resolver from "react-resolver";

Resolver.render(<Users />, document.getElementById("app"));
```


### Server

Because data has to be fetched asynchronously, `React.renderToString`
(and `React.renderToStaticMarkup`) won't have the data in time.

Instead, replace `React` with `Resolver` and you'll receive a promise
that resolves with the rendered output!

```javascript
import React from "react";
import Resolver from "react-resolver";

Resolver.renderToString(<Users />).then((string) => {
reply(string);
}).catch((err) {
// An error was thrown while rendering
console.error(err);
describe("Resolver", function() {
describe(".dom", function() {
it("should render a channel into dom", function(done) {
const ch = chan();
@dataDependencies({
user: ()=>ch
})
@displayName("TestElement")
class Element extends Component {
render(){
return <span>{this.props.user}</span>;
}
};
const resolver = new Resolver();
Resolver.render(
<Element/>
, document.body, resolver);

go(function* (){
yield put(ch,"Ernie");
yield timeout(0);
assert.equal(document.querySelector('span').innerHTML, 'Ernie');
yield put(ch,"Wise");
yield timeout(0);
assert.equal(document.querySelector('span').innerHTML, 'Wise');
done();
});
});
});
});

```

- - -

````
## Development

If you'd like to contribute to this project, all you need to do is clone
Expand All @@ -141,22 +90,6 @@ $ npm install
$ npm test
```

## Credits

## Authors

- [Eric Clemmons](mailto:eric@smarterspam.com>) ([@ericclemmons][twitter])


## [License][license]


## Collaboration

If you have questions or issues, please [open an issue][issue]!


[changelog]: https://github.com/ericclemmons/react-resolver/blob/master/CHANGELOG.md
[demo]: https://cdn.rawgit.com/ericclemmons/react-resolver/master/examples/stargazers/public/index.html
[issue]: https://github.com/ericclemmons/react-resolver/issues/new
[license]: https://github.com/ericclemmons/react-resolver/blob/master/LICENSE
[twitter]: https://twitter.com/ericclemmons/
[Based on ericclemmons/react-resolver](https://github.com/ericclemmons/react-resolver) and [iamdustan/react-resolver](https://github.com/iamdustan/react-resolver)
Loading