OOP is better with stamps: Composable object factories. News: https://twitter.com/stampit_org
koresar on master
Fix badge - bundle size (compare)
koresar on master
README refresh: remove bower, u… (compare)
@types/stampit
but trying it in codesandbox I got no type hinting.
4.3.1
version.import stampit from 'stampit'
const Character = stampit({
props: {
name: null,
health: 100
},
init({ name = this.name }) {
this.name = name
}
})
const Fighter = stampit(Character, { // inheriting
props: {
stamina: 100
},
init({ stamina = this.stamina }) {
this.stamina = stamina;
},
methods: {
fight() {
console.log(`${this.name} takes a mighty swing!`)
this.stamina--
}
}
})
const fighter = Fighter({ name: 'Thumper' }) // does not know about arguments that are needed
fighter.fight() // does not know about the "fight" method or method arguments