设计tracer
This commit is contained in:
@@ -21,8 +21,8 @@ export class ArrayTracer<T> {
|
|||||||
registry.register("ArrayTracer", arrayTracer.tracerId);
|
registry.register("ArrayTracer", arrayTracer.tracerId);
|
||||||
const commander = Commander.getInstance();
|
const commander = Commander.getInstance();
|
||||||
commander.command({
|
commander.command({
|
||||||
tracer: null,
|
|
||||||
action: "define",
|
action: "define",
|
||||||
|
tracer: null,
|
||||||
params: {
|
params: {
|
||||||
type: "ArrayTracer",
|
type: "ArrayTracer",
|
||||||
id: arrayTracer.tracerId,
|
id: arrayTracer.tracerId,
|
||||||
@@ -35,21 +35,63 @@ export class ArrayTracer<T> {
|
|||||||
public preset(array: T[]) {
|
public preset(array: T[]) {
|
||||||
const commander = Commander.getInstance();
|
const commander = Commander.getInstance();
|
||||||
commander.command({
|
commander.command({
|
||||||
tracer: this.tracerId,
|
|
||||||
action: "preset",
|
action: "preset",
|
||||||
|
tracer: this.tracerId,
|
||||||
params: array,
|
params: array,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public extend(size: number) {}
|
public extend(size: number) {
|
||||||
|
const commander = Commander.getInstance();
|
||||||
|
commander.command({
|
||||||
|
action: "extend",
|
||||||
|
tracer: this.tracerId,
|
||||||
|
params: { size },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public shrink(size: number) {}
|
public shrink(size: number) {
|
||||||
|
const commander = Commander.getInstance();
|
||||||
|
commander.command({
|
||||||
|
action: "shrink",
|
||||||
|
tracer: this.tracerId,
|
||||||
|
params: { size },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public pick(index: number) {}
|
public pick(index: number) {
|
||||||
|
const commander = Commander.getInstance();
|
||||||
|
commander.command({
|
||||||
|
action: "pick",
|
||||||
|
tracer: this.tracerId,
|
||||||
|
params: { index },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public drop(index: number) {}
|
public drop(index: number) {
|
||||||
|
const commander = Commander.getInstance();
|
||||||
|
commander.command({
|
||||||
|
action: "drop",
|
||||||
|
tracer: this.tracerId,
|
||||||
|
params: { index },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public patch(index: number, value: T) {}
|
public patch(index: number, value: T) {
|
||||||
|
const commander = Commander.getInstance();
|
||||||
|
commander.command({
|
||||||
|
action: "patch",
|
||||||
|
tracer: this.tracerId,
|
||||||
|
params: { index, value },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public reset(index: number) {}
|
public reset(index: number) {
|
||||||
|
const commander = Commander.getInstance();
|
||||||
|
commander.command({
|
||||||
|
action: "reset",
|
||||||
|
tracer: this.tracerId,
|
||||||
|
params: { index },
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export type ArrayTracerPatchCommand<T = unknown> = {
|
|||||||
export type ArrayTracerResetCommand = {
|
export type ArrayTracerResetCommand = {
|
||||||
action: "reset";
|
action: "reset";
|
||||||
tracer: string;
|
tracer: string;
|
||||||
params: null;
|
params: { index: number };
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ArrayTracerCommand<T = never> =
|
export type ArrayTracerCommand<T = never> =
|
||||||
|
|||||||
Reference in New Issue
Block a user