Skip to content

Instantly share code, notes, and snippets.

@alicewriteswrongs
Created September 5, 2023 15:23
Show Gist options
  • Save alicewriteswrongs/0a9844d33b0a0d18e3d62a06ece0b0a0 to your computer and use it in GitHub Desktop.
Save alicewriteswrongs/0a9844d33b0a0d18e3d62a06ece0b0a0 to your computer and use it in GitHub Desktop.
import { Component, Prop, h, Watch } from '@stencil/core';
import { format } from '../../utils/utils';
enum MyEnum {
first = 'first'
}
@Component({
tag: 'my-component',
styleUrl: 'my-component.css',
shadow: true,
})
export class MyComponent {
/**
* The first name
*/
@Prop() first: string;
@Watch(MyEnum.first)
firstChanged() {
console.log(this.first);
}
/**
* The middle name
*/
@Prop() middle: string;
/**
* The last name
*/
@Prop() last: string;
private getText(): string {
return format(this.first, this.middle, this.last);
}
render() {
return <div>Hello, World! I'm {this.getText()}</div>;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment