Skip to content

Instantly share code, notes, and snippets.

@kenanhancer
Created April 24, 2020 20:45
Show Gist options
  • Save kenanhancer/f26afafe3604ec1cbd4b74380db8977f to your computer and use it in GitHub Desktop.
Save kenanhancer/f26afafe3604ec1cbd4b74380db8977f to your computer and use it in GitHub Desktop.
uni-ioc classic code example
const helper = require('./helper');
const greetingService = {
sayHello: ({ firstName, lastName }) => {
const fullName = helper.getFullName({ firstName, lastName });
return `Hello ${fullName}`;
},
sayGoodbye: ({ firstName, lastName }) => {
const fullName = helper.getFullName({ firstName, lastName });
return `Goodbye, ${fullName}`;
}
};
module.exports = greetingService;
const helper = {
getFullName: ({firstName, lastName})=>{
return `${firstName} ${lastName}`;
}
};
module.exports = helper;
const greetingService = require('./greeting-service');
const helloMsg = greetingService.sayHello({firstName: "kenan", lastName: "hancer"});
console.log(helloMsg);
const goodBydMsg = greetingService.sayGoodbye({firstName: "kenan", lastName: "hancer"});
console.log(goodBydMsg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment