Last active
January 18, 2019 03:15
-
-
Save rxluz/c176ff5263dabff689193ad5c9aaf033 to your computer and use it in GitHub Desktop.
S.O.L.I.D Principles for JS with examples, see more at https://medium.com/p/db95b44e82e
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 Product { | |
setName({ name, onFinish = () => {} }) { | |
this.name = name; | |
onFinish(this); | |
} | |
} | |
const run = () => { | |
const ProductInstance = new Product(); | |
ProductInstance.setName({ | |
name: "Pen", | |
onFinish() { | |
console.log("Added succefully"); | |
}, | |
}); | |
// this will not generate any errors: | |
ProductInstance.setName({ | |
name: "Other pencil", | |
}); | |
}; | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment