Skip to content

how to setup dependent properties? #35

@hexsprite

Description

@hexsprite

not sure if there's a way to do this or not, looking at the code so far I think not...

but I want to be able to say something like:

Factory.define('event', Actions, {
    end () {
      if (!this.start || !this.duration) {
        throw new Error('must provide start and duration if end not specified')
      }
      return new Date(+this.start + this.duration)
    },
})

That would allow me to optionally provide start and duration. I notice that this object contains the statically defined properties, but not what the user provides as arguments to Factory.create

Any tips on how to implement that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions