Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
docs feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriscbr committed Aug 4, 2022
1 parent cba694a commit e6eaeb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ polycons can be used with any CDK framework, including [AWS CDK], [cdktf], and [
Polycons can be used just like ordinary CDK constructs:

```ts
import { Dog } from "my-polycons";
import { Dog } from "@acme/shared-polycons";
import { Construct } from "constructs";

class Pets extends Construct {
Expand All @@ -30,12 +30,12 @@ This construct contains a `Dog` from a library of polycons.
The dog could have any implementation -- a `Labrador` implementation, a `Terrier` implementation, and so on.

To use it in an application, you need to register a factory that specifies how to turn polycons into concrete constructs.
In the example below, a `PetFactory` is registered to the application, ensuring that each `Dog` defined in the construct tree will be resolved into a `Labrador` under the hood.
In the example below, a `PetFactory` is registered to the application, ensuring that each `Dog` defined in the construct tree will be resolved into a `Labrador`.

```ts
import { App } from "<cdk-framework>";
import { PetFactory } from "my-polycons";
import { Polycons } from "@monadahq/polycons";
import { PetFactory } from "@acme/shared-polycons";
import { Polycons } from "polycons";

const app = new App();
Polycons.register(app, new PetFactory());
Expand Down
10 changes: 5 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Polycon factories

To create a polycon factory, create a class with a `resolve` method.
This method takes a `type` and the polycon's constructor parameters, and should return a concrete construct. For example:
A polycon factory is an object that implements the `IPolyconFactory` interface, which has a single `resolve()` method.
This method takes a `type` and the construct arguments, and should return a concrete construct. For example:

```ts
import { DOG_ID, CAT_ID, Labrador, Kitten } from "my-polycons";
import { DOG_ID, CAT_ID, Labrador, Kitten } from "@acme/shared-polycons";

class PetFactory implements IPolyconFactory {
public resolve(
Expand All @@ -27,9 +27,9 @@ class PetFactory implements IPolyconFactory {
}
```

By customizing the `resolve` method, it's possible to change construct IDs, override properties, or even make factories out of other factories.
By customizing the `resolve()` method, it's possible to change construct IDs, override properties, or even make factories out of other factories.

## Polycons
## Authoring polycons

You can define a polycon by creating a class that returns a new Polycon instance in the constructor. Each polycon must be associated with a unique identifier.

Expand Down

0 comments on commit e6eaeb1

Please sign in to comment.