Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.
/ adonis-true-traits Public archive

The real traits for AdonisJS Framework (extending the class with native `extend` function

License

Notifications You must be signed in to change notification settings

mikield/adonis-true-traits

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to Adonis True Traits 👋

Version Documentation Maintenance License: MIT Twitter: AdmiralMiki

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

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

About

The real traits for AdonisJS Framework (extending the class with native `extend` function

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published