Skip to content

Commit 502378e

Browse files
committed
remove unused Behavior class
1 parent 5114156 commit 502378e

File tree

1 file changed

+0
-97
lines changed

1 file changed

+0
-97
lines changed

src/lib/behavior.ts

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -16,103 +16,6 @@ export class BackgroundBehavior {
1616
}
1717
}
1818

19-
// ===========================================================================
20-
export class Behavior<State> extends BackgroundBehavior {
21-
_running: Promise<void> | null;
22-
paused: Promise<void> | null;
23-
_unpause: (() => void) | null;
24-
state: Partial<State>;
25-
scrollOpts: {
26-
behavior: string;
27-
block: string;
28-
inline: string;
29-
};
30-
31-
constructor() {
32-
super();
33-
this._running = null;
34-
this.paused = null;
35-
this._unpause = null;
36-
this.state = {};
37-
38-
this.scrollOpts = { behavior: "smooth", block: "center", inline: "center" };
39-
}
40-
41-
start() {
42-
this._running = this.run();
43-
}
44-
45-
async done() {
46-
return this._running ? this._running : Promise.resolve();
47-
}
48-
49-
async run() {
50-
try {
51-
for await (const step of this) {
52-
this.debug(step);
53-
if (this.paused) {
54-
await this.paused;
55-
}
56-
}
57-
this.debug(this.getState("done!"));
58-
} catch (e) {
59-
this.error((e as Error).toString());
60-
}
61-
}
62-
63-
pause() {
64-
if (this.paused) {
65-
return;
66-
}
67-
this.paused = new Promise((resolve) => {
68-
this._unpause = resolve;
69-
});
70-
}
71-
72-
unpause() {
73-
if (this._unpause) {
74-
this._unpause();
75-
this.paused = null;
76-
this._unpause = null;
77-
}
78-
}
79-
80-
getState<IncrKey extends Lib.NumberKeys<State>>(
81-
msg: string,
82-
incrValue?: IncrKey,
83-
) {
84-
if (incrValue) {
85-
if (this.state[incrValue] === undefined) {
86-
(this.state[incrValue] as number) = 1;
87-
} else {
88-
(this.state[incrValue] as number)++;
89-
}
90-
}
91-
92-
return { state: this.state, msg };
93-
}
94-
95-
cleanup() {}
96-
97-
async awaitPageLoad() {
98-
// wait for initial page load here
99-
}
100-
101-
static load() {
102-
if (self["__bx_behaviors"]) {
103-
self["__bx_behaviors"].load(this);
104-
} else {
105-
console.warn(
106-
`Could not load ${this.name} behavior: window.__bx_behaviors is not initialized`,
107-
);
108-
}
109-
}
110-
111-
async *[Symbol.asyncIterator]() {
112-
yield;
113-
}
114-
}
115-
11619
// WIP: BehaviorRunner class allows for arbitrary behaviors outside of the
11720
// library to be run through the BehaviorManager
11821

0 commit comments

Comments
 (0)