Skip to content

Commit 3144988

Browse files
authored
Merge pull request #68 from dtex/Relay
Relay
2 parents e152e37 + 2983c95 commit 3144988

14 files changed

Lines changed: 2811 additions & 597 deletions

File tree

build/templates/class.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Class template
3+
* @module j5e/XXX
4+
* @requires module:j5e/event
5+
* @requires module:j5e/fn
6+
*/
7+
8+
import { Emitter } from "j5e/event";
9+
import { normalizeParams, getProvider } from "j5e/fn";
10+
11+
/**
12+
* Class representing XXX
13+
* @classdesc The XXX class allows for control of XXX
14+
* @async
15+
* @extends Emitter
16+
* @fires Switch#XXX
17+
* @fires Switch#XXX
18+
*/
19+
class XXX extends Emitter {
20+
21+
#state = {
22+
someStateProp: true
23+
};
24+
25+
/**
26+
* Instantiate XXX
27+
* @param {object} options - A pin number, pin identifier or a complete IO options object (See {@tutorial C-INSTANTIATING}
28+
* @property {boolean} XXX - True if XXX
29+
* @example
30+
* <caption>Use an XXX</caption>
31+
* import XXX from "j5e/XXX";
32+
*
33+
* const myxxx = await new XXX(12);
34+
*
35+
*/
36+
constructor(options) {
37+
return (async() => {
38+
options = normalizeParams(options);
39+
super();
40+
41+
const Provider = await getProvider(options, "builtin/digital");
42+
this.io = new Provider({
43+
pin: options.pin,
44+
mode: Provider.Input,
45+
onReadable: () => {
46+
this.emit(this.isOpen ? "open" : "close");
47+
}
48+
});
49+
50+
Object.defineProperties(this, {
51+
XXX: {
52+
get: () => {
53+
return Boolean(this.io.XXX);
54+
}
55+
}
56+
});
57+
58+
return this;
59+
})();
60+
61+
}
62+
63+
/**
64+
* doSomething
65+
* @return {XXX}
66+
* @example
67+
* import XXX from "j5e/XXX";
68+
*
69+
* const myXXX = await new XXX(12);
70+
* myXXX.doSomething();
71+
*/
72+
doSomething() {
73+
return this;
74+
}
75+
76+
}
77+
78+
export default XXX;

0 commit comments

Comments
 (0)