Skip to content

Commit

Permalink
feat(all): rename manager/registry to featureAppManager/featureServic…
Browse files Browse the repository at this point in the history
…eRegistry (#247)

This is in preparation for the task "Integrate Async SSR Manager into FeatureAppLoader" of #25, where the new prop asyncSsrManager will be added to the FeatureAppLoader.
  • Loading branch information
unstubbable committed Jan 10, 2019
1 parent af946fa commit f662c45
Show file tree
Hide file tree
Showing 14 changed files with 258 additions and 158 deletions.
49 changes: 31 additions & 18 deletions docs/guides/integrating-the-feature-hub.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ import {someFeatureServiceDefinition2} from './some-feature-service-2';
```

```js
const registry = new FeatureServiceRegistry();
const featureServiceRegistry = new FeatureServiceRegistry();

const featureServiceDefinitions = [
someFeatureServiceDefinition1,
someFeatureServiceDefinition2
];

registry.registerFeatureServices(featureServiceDefinitions, 'acme:integrator');
featureServiceRegistry.registerFeatureServices(
featureServiceDefinitions,
'acme:integrator'
);

const manager = new FeatureAppManager(registry);
const featureAppManager = new FeatureAppManager(featureServiceRegistry);
```

**Note:** The integrator needs a self-selected but unique consumer ID to
Expand All @@ -64,7 +67,9 @@ import {loadAmdModule} from '@feature-hub/module-loader-amd';
```

```js
const manager = new FeatureAppManager(registry, {moduleLoader: loadAmdModule});
const featureAppManager = new FeatureAppManager(featureServiceRegistry, {
moduleLoader: loadAmdModule
});
```

On the server:
Expand All @@ -74,7 +79,7 @@ import {loadCommonJsModule} from '@feature-hub/module-loader-commonjs';
```

```js
const manager = new FeatureAppManager(registry, {
const featureAppManager = new FeatureAppManager(featureServiceRegistry, {
moduleLoader: loadCommonJsModule
});
```
Expand Down Expand Up @@ -103,7 +108,7 @@ import {FeatureAppLoader} from '@feature-hub/react';

```jsx
<FeatureAppLoader
manager={manager}
featureAppManager={featureAppManager}
src="https://example.com/some-feature-app.js"
/>
```
Expand All @@ -118,7 +123,7 @@ Additionally, when a Feature App needs to be rendered on the server, its

```jsx
<FeatureAppLoader
manager={manager}
featureAppManager={featureAppManager}
src="https://example.com/some-feature-app.js"
serverSrc="https://example.com/some-feature-app-node.js"
/>
Expand All @@ -134,7 +139,7 @@ You can also define a `css` prop to add stylesheets to the document:

```jsx
<FeatureAppLoader
manager={manager}
featureAppManager={featureAppManager}
src="https://example.com/some-feature-app.js"
css={[
{href: 'https://example.com/some-feature-app.css'},
Expand All @@ -153,14 +158,14 @@ integrator:
<section>
<div>
<FeatureAppLoader
manager={manager}
featureAppManager={featureAppManager}
src="https://example.com/some-feature-app.js"
idSpecifier="main"
/>
</div>
<aside>
<FeatureAppLoader
manager={manager}
featureAppManager={featureAppManager}
src="https://example.com/some-feature-app.js"
idSpecifier="aside"
/>
Expand All @@ -185,7 +190,7 @@ import {someFeatureAppDefinition} from './some-feature-app';

```jsx
<FeatureAppContainer
manager={manager}
featureAppManager={featureAppManager}
featureAppDefinition={someFeatureAppDefinition}
/>
```
Expand All @@ -200,14 +205,14 @@ integrator:
<section>
<div>
<FeatureAppContainer
manager={manager}
featureAppManager={featureAppManager}
featureAppDefinition={someFeatureAppDefinition}
idSpecifier="main"
/>
</div>
<aside>
<FeatureAppContainer
manager={manager}
featureAppManager={featureAppManager}
featureAppDefinition={someFeatureAppDefinition}
idSpecifier="aside"
/>
Expand All @@ -225,8 +230,13 @@ associated with their respective IDs, via the `FeatureServiceRegistry` and
const featureServiceConfigs = {'acme:some-feature-service': {foo: 'bar'}};
const featureAppConfigs = {'acme:some-feature-app': {baz: 'qux'}};

const registry = new FeatureServiceRegistry({configs: featureServiceConfigs});
const manager = new FeatureAppManager(registry, {configs: featureAppConfigs});
const featureServiceRegistry = new FeatureServiceRegistry({
configs: featureServiceConfigs
});

const featureAppManager = new FeatureAppManager(featureServiceRegistry, {
configs: featureAppConfigs
});
```

Feature Services and Feature Apps can then use their respective config object as
Expand Down Expand Up @@ -279,19 +289,22 @@ const integratorDefinition = {
}
};

const registry = new FeatureServiceRegistry();
const featureServiceRegistry = new FeatureServiceRegistry();

const featureServiceDefinitions = [
someFeatureServiceDefinition1,
someFeatureServiceDefinition2
];

registry.registerFeatureServices(
featureServiceRegistry.registerFeatureServices(
featureServiceDefinitions,
integratorDefinition.id
);

const {featureServices} = registry.bindFeatureServices(integratorDefinition);
const {featureServices} = featureServiceRegistry.bindFeatureServices(
integratorDefinition
);

const someFeatureService2 = featureServices[someFeatureServiceDefinition2.id];

someFeatureService2.foo(42);
Expand Down
4 changes: 3 additions & 1 deletion docs/guides/sharing-npm-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import Loadable from 'react-loadable';
```js
defineExternals({react: React, 'react-loadable': Loadable});

const manager = new FeatureAppManager(registry, {moduleLoader: loadAmdModule});
const featureAppManager = new FeatureAppManager(featureServiceRegistry, {
moduleLoader: loadAmdModule
});
```

Feature Apps should define these externals in their build config. For example,
Expand Down
14 changes: 10 additions & 4 deletions docs/guides/sharing-the-browser-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ import {
```

```js
const registry = new FeatureServiceRegistry();
const featureServiceRegistry = new FeatureServiceRegistry();

const rootLocationTransformer = createRootLocationTransformer({
consumerPathsQueryParamName: '---'
Expand All @@ -126,15 +126,18 @@ const featureServiceDefinitions = [
defineHistoryService(rootLocationTransformer)
];

registry.registerFeatureServices(featureServiceDefinitions, 'acme:integrator');
featureServiceRegistry.registerFeatureServices(
featureServiceDefinitions,
'acme:integrator'
);
```

On the server, the integrator defines the Async SSR Manager using the request.
The History Service depends on the Async SSR Manager to obtain its request and
use it for the initial history location:

```js
const registry = new FeatureServiceRegistry();
const featureServiceRegistry = new FeatureServiceRegistry();

const rootLocationTransformer = createRootLocationTransformer({
consumerPathsQueryParamName: '---'
Expand All @@ -149,7 +152,10 @@ const featureServiceDefinitions = [
defineHistoryService(rootLocationTransformer)
];

registry.registerFeatureServices(featureServiceDefinitions, 'acme:integrator');
featureServiceRegistry.registerFeatureServices(
featureServiceDefinitions,
'acme:integrator'
);
```

## Root Location Transformer
Expand Down

0 comments on commit f662c45

Please sign in to comment.