Skip to content

Commit

Permalink
Factor out PromiseUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
taion committed Oct 27, 2016
1 parent 75a1ac7 commit c132a9c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
15 changes: 15 additions & 0 deletions src/PromiseUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import isPromise from 'is-promise';

const UNRESOLVED = {};

export function checkResolved(value) {
if (!isPromise(value)) {
return value;
}

return Promise.race([value, UNRESOLVED]);
}

export function isResolved(value) {
return value !== UNRESOLVED;
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export HttpError from './HttpError';
export Link from './Link';
export Matcher from './Matcher';
export matchReducer from './matchReducer';
export PromiseUtils from './PromiseUtils';
export Redirect from './Redirect';
export RedirectException from './RedirectException';
export resolveElements from './resolveElements';
14 changes: 1 addition & 13 deletions src/resolveElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@ import isPromise from 'is-promise';
import React from 'react';
import warning from 'warning';

const UNRESOLVED = {};

function checkResolved(value) {
if (!isPromise(value)) {
return value;
}

return Promise.race([value, UNRESOLVED]);
}

function isResolved(value) {
return value !== UNRESOLVED;
}
import { checkResolved, isResolved } from './PromiseUtils';

function createElements(match, Components, matchData) {
const { routes, routeParams: matchRouteParams } = match;
Expand Down

0 comments on commit c132a9c

Please sign in to comment.