ObjectModel icon indicating copy to clipboard operation
ObjectModel copied to clipboard

How to add custom methods to a Model?

Open DaviidMM opened this issue 3 years ago • 0 comments

Using for example a ObjectModel, how can I add method or functions to it?

In the following example, how can I add or create the method getColor() so it returns thecolor property of the object davidm ?

const Person = ObjectModel({
  name: String,
  color: String
})

const davidm = Person({
  name: 'David',
  color: 'red'
})

console.log(davidm.getColor())

Thank you beforehand 😄

DaviidMM avatar Jun 06 '22 13:06 DaviidMM