Skip to content

Commit

Permalink
Migrates to rollup and yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlplusb committed Mar 21, 2018
1 parent 0ec74a4 commit 7704326
Show file tree
Hide file tree
Showing 20 changed files with 5,432 additions and 9,439 deletions.
28 changes: 7 additions & 21 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
{
"presets": [
["env", { "targets": { "node": true } }],
"stage-3",
"react"
],
"env": {
"commonjs": {
"presets": [
"latest",
"stage-3",
"react"
],
},
"umd": {
"presets": [
["latest", { "es2015": { "modules": false } }],
"stage-3",
"react"
],
}
}
}
["env", {
"targets": {
"node": true
}
}], "stage-3", "react"
]
}
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ npm-debug.log
# Jest
coverage

# Flow
flow-coverage
flow-typed
# Build
dist

# IDEs
.vscode
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
sudo: false
language: node_js
cache:
npm: true
yarn: true
directories:
- node_modules
node_js:
- '8'
script:
- npm run test
- npm run precommit
after_success:
# Deploy code coverage report to codecov.io
- npm run test:coverage:deploy
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ Provides the ability to execute async bootstrapper functions within your React e

## Introduction

This library is an abstraction of [`react-tree-walker`](https://github.com/ctrlplusb/react-tree-walker), that allows you to attach an `asyncBootstrap` member to your React components.
This library is an abstraction of [`react-tree-walker`](https://github.com/ctrlplusb/react-tree-walker), that allows you to attach an `asyncBootstrap` method to your React "class" components.

Within the `asyncBootstrap` you can do any work/bootstrapping that you like and then return a `Promise` that should resolve to either `true` (which indicates back to the bootstrapping process that it should continue down the current branch of your application in order to locate and resolve any nested `asyncBootstrap` instances), or `false` (which indicates that traversal of the current branch of your application can stop).
Within the `asyncBootstrap` you can do any asynchronous work you like (e.g. fetching data) that you like, returning a `Promise` to indicate when the asynchronous work has completed.

## Naive Example

```jsx
import asyncBootstrapper from 'react-async-bootstrapper'

// Don't do this, do a proper imp
// Our super naive global state. Don't copy this, it's just illustrative. You'd
// likely want to use something
const globalStateManager = {
products: {},
}
Expand All @@ -32,11 +33,10 @@ class Product extends Component {
 // 👇
 asyncBootstrap() {
if (globalStateManager.products[this.props.productId]) {
// Already have data, just return true to allow nested
// asyncBootstrap instances to be located/resolved
return true
// Already have data
return
}

// Fetch our product and load up our state
return fetch(`/api/products/${this.props.productId}`)
.then((response) => {
Expand Down
23 changes: 0 additions & 23 deletions commonjs/index.js

This file was deleted.

Loading

0 comments on commit 7704326

Please sign in to comment.