From 94ec1c5c9cf01d5ee13333fd7077bc6c4b7e383a Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sun, 4 Feb 2018 10:41:57 -0800 Subject: [PATCH] Expose middleware https://github.com/fusionjs/fusion-react-async/pull/44 --- README.md | 8 ++++---- src/index.js | 4 ++-- src/{plugin.js => middleware.js} | 5 +---- 3 files changed, 7 insertions(+), 10 deletions(-) rename src/{plugin.js => middleware.js} (76%) diff --git a/README.md b/README.md index 9e26900..70ec9a1 100644 --- a/README.md +++ b/README.md @@ -97,15 +97,15 @@ export default () => ( ### API -#### PreparePlugin +#### middleware ```js -import {PreparePlugin} from 'fusion-react-async'; +import {middleware} from 'fusion-react-async'; ``` -A plugin that adds a `PrepareProvider` to the React tree. +A middleware that adds a `PrepareProvider` to the React tree. -You should consider using [`fusion-react`](https://github.com/fusionjs/fusion-react) instead of setting up React and registering this plugin manually, since that package does all of that for you. +You should consider using [`fusion-react`](https://github.com/fusionjs/fusion-react) instead of setting up React and registering this middleware manually, since that package does all of that for you. #### split diff --git a/src/index.js b/src/index.js index 601f7a2..d9b8cfe 100644 --- a/src/index.js +++ b/src/index.js @@ -9,7 +9,7 @@ import prepare from './prepare'; import prepared from './prepared'; import split from './split'; import exclude from './traverse-exclude'; -import PreparePlugin from './plugin'; +import middleware from './middleware'; // TODO(#3): Can we get ride of some of these exports? -export {dispatched, prepare, prepared, split, exclude, PreparePlugin}; +export {dispatched, prepare, prepared, split, exclude, middleware}; diff --git a/src/plugin.js b/src/middleware.js similarity index 76% rename from src/plugin.js rename to src/middleware.js index 1c46e57..43edb51 100644 --- a/src/plugin.js +++ b/src/middleware.js @@ -6,7 +6,7 @@ import React from 'react'; import PrepareProvider from './prepare-provider'; -function preparePlugin(ctx, next) { +export default function(ctx, next) { if (__NODE__ && !ctx.element) { return next(); } @@ -17,6 +17,3 @@ function preparePlugin(ctx, next) { ); return next(); } - -// wrap in function in case we need to take config in the future -export default () => preparePlugin;