Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify example "Export boundary functions" #1221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ var Module = fx.Module("server",
),
)

type Config struct {
type Params struct {
fx.In

Addr string `yaml:"addr"`
Comment on lines +136 to 139
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config isn't intended to be a parameter object. It is being passed into New through a Params struct.
Although I agree that this example is a tad confusing: Params and parseConfig aren't visible, and we just assume that a reader knows what they are.

The text in this example is generated automatically from ex/modules/module.go; it may require some adjustment in the snippets there to update this.

}

Expand All @@ -142,7 +144,7 @@ func New(p Params) (Result, error) {

In this example, we don't export `parseConfig`,
because it's a trivial `yaml.Decode` that we don't need to expose,
but we still export `Config` so users can decode it themselves.
but we still export `Params` so users can decode it themselves.

**Rationale**:
It should be possible to use your Fx module without using Fx itself.
Expand Down