skimia-sef
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Skimia Extension Framework (SEF)

the goal of this project is handle the new developpement way (such as php traits), using "mixin" decorators

Install

Install with npm

npm i skimia-sef --save

TODO

  • [ ] find a way to configure mixins
  • [ ] add events (on instance creation to call all "mixinConstructors")
  • [ ] export to a new package

Exemple

//mixin definition
const Resource = mixin('MixinName', {
    //access to local property in underscored snake case
    Premium() : boolean {
        return this._is_premium || (this._is_premium = false)
    },
    //setter
    setPremium(value:boolean) : IResource{
        this._is_premium = value
        return this
    }
}, {
    //Array of mixinNames dependent for this mixin
    dependencies: []
});
//mixin interface
interface IResource{
    Premium() : boolean
    setPremium(value:boolean) : IResource
}

//apply mixin
@Resource
class ResourceTemplate{
}

//fix (apply mixin interface)
interface ResourceTemplate extends IResource {}

//use
let rezz = new ResourceTemplate()
rezz.setPremium(true)
console.log(rezz.Premium()); // => true

Note:

  • a mixin cannot redefine class members
  • MixinName in PascalCase
  • Property in PascalCase
  • private var in underscored snake_case
  • volatile var in doubleunderscored snake_case => __volatile (ex state)

Readme

Keywords

none

Package Sidebar

Install

npm i skimia-sef

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • kesslerdev