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

Refactor addComputedFields #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ricardo-valero
Copy link

  • Rename to addFields
  • Convert to a callback function

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This renames the addComputedFields to simply addFields and refactors the definition of adding computed fields to a callback function, thereby eliminating the need to repeatedly write the same callback for each property's resolve function.

Before

.addComputedFields({
  slug: { schema: Schema.NonEmptyString, resolve: (fields, source) => Effect.succeed(source.path) },
  title2: { schema: Schema.NonEmptyString, resolve: (fields, source) => Effect.succeed(fields.title.slice(0, 5)) }
})

After

.addFields((fields, source) => ({
  slug: { schema: Schema.NonEmptyString, resolve: Effect.succeed(source.path) },
  title2: { schema: Schema.NonEmptyString, resolve: Effect.succeed(fields.title.slice(0, 5)) }
}))

Related

  • Related Issue #
  • Closes #

- Rename to `addFields`
- Convert to a callback function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant