Particle lifecycle events
Handle the discriminated event and diagnostic records.
APIs demonstrated
Section titled “APIs demonstrated”- PibblParticleBurstAcceptedEvent from
@pibbl/core/particles - PibblParticleBurstRejectedEvent from
@pibbl/core/particles - PibblParticleDiagnostic from
@pibbl/core/particles - PibblParticleDrainStartEvent from
@pibbl/core/particles - PibblParticleFinishEvent from
@pibbl/core/particles - PibblParticleStartEvent from
@pibbl/core/particles - PibblParticleSystemEvent from
@pibbl/core/particles
Complete example
Section titled “Complete example”Plain source. Run as a browser module after the document body exists. TSX uses jsx: "react-jsx" and jsxImportSource: "@pibbl/core".
import { type PibblParticleBurstAcceptedEvent, type PibblParticleBurstRejectedEvent, type PibblParticleDiagnostic, type PibblParticleDrainStartEvent, type PibblParticleFinishEvent, type PibblParticleStartEvent, type PibblParticleSystemEvent,} from "@pibbl/core/particles";
const started: PibblParticleStartEvent = { type: "start" };const accepted: PibblParticleBurstAcceptedEvent = { type: "burst-accepted", emitter: "spark", requested: 12, accepted: 12,};const rejected: PibblParticleBurstRejectedEvent = { type: "burst-rejected", emitter: "spark", requested: 12, accepted: 0, reason: "capacity",};const draining: PibblParticleDrainStartEvent = { type: "drain-start" };const finished: PibblParticleFinishEvent = { type: "finish" };const events: PibblParticleSystemEvent[] = [ started, accepted, rejected, draining, finished,];const diagnostic: PibblParticleDiagnostic = { type: "capacity-rejected", message: "The emitter has reached its capacity.", emitter: rejected.emitter,};
const output = document.createElement("pre");output.textContent = [ ...events.map((event) => event.type), diagnostic.message,].join("\n");document.body.append(output);Usage notes
Section titled “Usage notes”- Displays the event sequence and diagnostic in the document.
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.