Skip to content

Instantly share code, notes, and snippets.

@colinrotherham
Last active August 31, 2017 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinrotherham/8fcf7845a7a2847876ced463843f4435 to your computer and use it in GitHub Desktop.
Save colinrotherham/8fcf7845a7a2847876ced463843f4435 to your computer and use it in GitHub Desktop.
Example ES6 class
import Etiquette from './lib/etiquette';
import message from './lib/message';
class Greeter extends Etiquette {
constructor (config) {
super();
this.intro = config.intro;
this.name = config.name;
}
message (greeting) {
console.log(`${greeting} ${this.name}`);
}
async hello () {
const greeting = await message.waitUntilArrive();
this.message(greeting);
}
async goodbye () {
const farewell = await message.waitUntilExit();
this.message(farewell);
}
}
const example = new Greeter({
intro: 'Hello',
name: 'Colin Rotherham'
});
try {
example.hello();
example.goodbye();
} catch (err) {
console.err(err);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment