Created
March 10, 2018 14:23
-
-
Save nomanHasan/9d247abeb22f79fff2b61f59001254b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Action { | |
constructor(type = '', model = '') { | |
this.type = ` ${type.toUpperCase().replace(' ', '_')}_`; | |
this.model = model; | |
this.modelString = `[${model}]`; | |
this.upperModel = this.model.toUpperCase(); | |
this.request = this.modelString + | |
this.type +this.model.toUpperCase(); | |
this.success = this.modelString + | |
this.type +this.model.toUpperCase()+'_SUCCESS'; | |
this.failure = this.modelString + | |
this.type +this.model.toUpperCase() + '_FAILURE'; | |
} | |
} | |
class ModelAction { | |
constructor(model) { | |
this.model = model; | |
this.create = new Action('create', this.model); | |
this.read = new Action('get', this.model); | |
this.update = new Action('update', this.model); | |
this.remove = new Action('remove', this.model); | |
} | |
} | |
class CustomModelAction extends ModelAction{ | |
constructor(model) { | |
super(model); | |
this.startEdit = new Action('start edit', this.model); | |
} | |
} | |
const actions = [new ModelAction('Todo'), new ModelAction('Song'), new ModelAction('Event'), new CustomModelAction('User') ]; | |
console.log(actions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment