use callbag-pipe
This commit is contained in:
parent
48940e1073
commit
33eb28e338
4 changed files with 745 additions and 637 deletions
1353
package-lock.json
generated
1353
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -23,6 +23,7 @@
|
|||
"callbag": "^1.2.0",
|
||||
"callbag-animation-frames": "^2.1.0",
|
||||
"callbag-map": "^1.1.0",
|
||||
"callbag-pipe": "^1.2.0",
|
||||
"callbag-subscribe": "^1.5.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import pipe from "callbag-pipe";
|
||||
import subscribe from "callbag-subscribe";
|
||||
|
||||
import { KeyControl, KeyName } from "../Applet/Keyboard";
|
||||
|
@ -20,6 +21,8 @@ export class Main extends LockstepClient<KeyName[], Data> {
|
|||
|
||||
this.connect(Loopback);
|
||||
|
||||
pipe(
|
||||
this.renderFrames,
|
||||
subscribe((frame: Data) => {
|
||||
const drawSet = new DrawSet();
|
||||
cx.fillStyle = "#000";
|
||||
|
@ -28,7 +31,8 @@ export class Main extends LockstepClient<KeyName[], Data> {
|
|||
RunRenderBounds(frame, drawSet);
|
||||
|
||||
drawSet.draw(cx, 0);
|
||||
})(this.renderFrames);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
gatherInput() {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import { Callbag } from "callbag";
|
||||
import animationFrames from "callbag-animation-frames";
|
||||
import map from "callbag-map";
|
||||
import pipe from "callbag-pipe";
|
||||
|
||||
import { INPUT_FREQUENCY, LockstepProcessor, LockstepState } from "../Ecs/Lockstep";
|
||||
|
||||
|
@ -88,5 +89,8 @@ export abstract class LockstepClient<Input, State> {
|
|||
};
|
||||
}
|
||||
|
||||
public renderFrames = map((ms: number) => this.state.getStateToRender())(animationFrames);
|
||||
public renderFrames = pipe(
|
||||
animationFrames,
|
||||
map(_ms => this.state.getStateToRender())
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue