MCPcopy Create free account
hub / github.com/EasyWebApp/WebCell / ClassClock

Class ClassClock

preview/Clock.tsx:43–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41})
42@observer
43export class ClassClock extends HTMLElement implements WebCell {
44 @attribute
45 @observable
46 accessor time = new Date();
47
48 private timer: number;
49
50 connectedCallback() {
51 this.timer = window.setInterval(() => (this.time = new Date()), Second);
52 }
53
54 disconnectedCallback() {
55 clearInterval(this.timer);
56 }
57
58 @reaction(({ time }) => time)
59 handleReaction(newValue: Date, oldValue: Date, reaction: IReactionPublic) {
60 console.info(newValue, oldValue, reaction);
61 }
62
63 @on('click', 'time')
64 handleClick(event: MouseEvent, currentTarget: HTMLTimeElement) {
65 console.info(event, currentTarget);
66 }
67
68 render() {
69 const { time } = this;
70
71 return (
72 <time dateTime={time.toJSON()}>
73 Class Clock: {time.toLocaleString()}
74 </time>
75 );
76 }
77}

Callers

nothing calls this directly

Calls 2

reactionFunction · 0.90
onFunction · 0.90

Tested by

no test coverage detected