Loading...
Loading...
Invoked when user wants to implement specific state modules in TypeScript for Bun runtime environment in GraphiCode-managed projects. Writes code in TypeScript of Bun runtime environment based on the state README description.
npx skill4agent add sien75/graphicode-skills graphicode-junior-engineer-ts-state-bun./references/state.mdBunclassSubscription_subscribe_publish# read
## readData1
> TypeX
TypeA
## readData2
TypeB
TypeC
# write
## writeData1
TypeD
## writeData2
TypeE
TypeF
TypeG
# event
## onEvent1
TypeH
## onEvent2
TypeI
# resides-in
memory
# description
This state is a memory state, which means...import { Subscription, Status } from 'graphicode-utils';
import TypeX from '../../types/TypeX';
import TypeA from '../../types/TypeA';
import TypeB from '../../types/TypeB';
import TypeC from '../../types/TypeC';
import TypeD from '../../types/TypeD';
import TypeE from '../../types/TypeE';
import TypeF from '../../types/TypeF';
import TypeG from '../../types/TypeG';
import TypeH from '../../types/TypeH';
import TypeI from '../../types/TypeI';
class XXX extends Subscription implements Status {
private someState: xxx;
public enabled = false; // disabled initially
public enable() {
// write init code here, do not write in constructor
this.enabled = true;
}
public disable() {
// write unmount code here
this.enabled = false;
}
public readData1(params: { x: TypeX }): { a: TypeA } {
return { a };
}
public readData2(): { b: TypeB; c: TypeC } {
return { b, c };
}
public writeData1(data: { d: TypeD }) {
// xxx
}
public writeData2(data: { e: TypeE; f: TypeF; g: TypeG }) {
// xxx
}
// "id" here will be flow id padding algorithm id
public onEvent1(id: string, callback: (data: { h: TypeH }) => void) {
this._subscribe(id, 'onEvent1', callback);
}
public onEvent2(id: string, callback: (data: { i: TypeI }) => void) {
this._subscribe(id, 'onEvent2', callback);
}
private someMethod() {
this.someState.xxx = xxx;
this._publish('onEvent1', { h });
}
}
const xxx = new XXX();
export default xxx;BunBun./references/bun.mdcat ./<stateDir>/<stateId>/README.mdecho '...' > ./<stateDir>/<stateId>/index.ts