Skip to content

Reusing BaseElementField #64

Answered by adamberecz
dan-leech asked this question in Questions
Jun 13, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

I would take a different approach of using named exports for the schema of each field:

// FieldA.js

const schema = function () {
  return {
    fieldA: {
      // ...
    }
  }
}

export default class FieldA extends BaseElementField
{
    name = 'FieldA'

    get schema () {
      return schema.call(this)
    }
}

export {
  schema,
}
// FieldB.js

import { schema as fieldASchema } from './FieldA.js'

const schema = function () {
  const schemaA = fieldASchema.call(this)

  return {
    fieldB: {
      // ...
    }
  }
}

export default class FieldB extends BaseElementField
{
    name = 'FieldB'

    get schema () {
      return schema.call(this)
    }
}

export {
  schema,
}
// FieldC.js

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@dan-leech
Comment options

@adamberecz
Comment options

Answer selected by dan-leech
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants