Skip to content

Instantly share code, notes, and snippets.

@rxluz
Last active January 18, 2019 02:32
Show Gist options
  • Save rxluz/76a3ffea82eff3f7fdee39c25f18e2f8 to your computer and use it in GitHub Desktop.
Save rxluz/76a3ffea82eff3f7fdee39c25f18e2f8 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
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");
},
});
ProductInstance.setName({
name: "Pencil",
onFinish() {},
});
// this is generate a error:
ProductInstance.setName({
name: "Other pencil",
});
//returns TypeError: onFinish is not a function
};
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment