0.0.7 ā€¢ Published 4 years ago

@mikield/adonis-true-traits v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

The true traits for AdonisJS Framework (extending the class with native extend function)

šŸ  Homepage

Install

adonis install @mikield/adonis-true-traits

Registering provider

Make sure you register the provider inside start/app.js file before making use.

const providers = [
  ...,
  '@mikield/adonis-true-traits'
]

Usage

mix(SomeClass).with(SomeTrait, AnotherTrait, ...)
Mixin a User model with MyTrait class
"use strict";

const Model = use('Model')
const MyTrait = use('App/Models/Traits/MyTrait')

class User extends Model {
 
}

module.exports = mix(User).with(MyTrait)

A exampole of MyTrait class

"use strict";

const Trait = (Model) => class extends Model {
    myFunction(){
      return "Hi from the Trait"
    }

    get myParam(){
      return "The param from Trait"
    }
}

module.exports = Trait;

Author

šŸ‘¤ Vladyslav Gaysyuk mikield@icloud.com

šŸ¤ Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ā­ļø if this project helped you!

šŸ“ License

Copyright Ā© 2020 Vladyslav Gaysyuk <mikield@icloud.com>. This project is MIT licensed.


This README was generated with ā¤ļø by readme-md-generator