Skip to content

Instantly share code, notes, and snippets.

@rxluz
Last active January 18, 2019 03:15
Show Gist options
  • Save rxluz/c176ff5263dabff689193ad5c9aaf033 to your computer and use it in GitHub Desktop.
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
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