CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-wolfy87-eventemitter

Event based JavaScript for the browser with comprehensive event management API

91

1.26x
Overview
Eval results
Files

task.mdevals/scenario-1/

Event-Driven Task Processor

Build a task processing system that uses an event emitter to coordinate multiple task stages. The system should leverage fluent API patterns for configuration and provide listeners access to the event system context.

Requirements

The task processor should:

  1. Support chaining of configuration operations when setting up event handlers
  2. Allow event listeners to access the event system itself to emit follow-up events
  3. Process tasks through multiple stages: 'prepare', 'execute', 'validate', and 'complete'
  4. Support a fluent initialization pattern where multiple handlers can be registered in a chain

Core Functionality

  • When a task is started, emit a 'prepare' event
  • The 'prepare' event handler should have access to emit an 'execute' event after preparation
  • The 'execute' event handler should emit a 'validate' event after execution
  • The 'validate' event handler should emit a 'complete' event after validation
  • All event registrations should be chainable to allow fluent configuration

Test Cases

  • The processor allows chaining multiple event listener registrations (e.g., processor.on('prepare', fn1).on('execute', fn2).on('validate', fn3)) @test
  • A 'prepare' event listener can emit an 'execute' event using the event system context @test
  • Starting a task triggers the complete sequence: prepare → execute → validate → complete @test

Implementation

@generates

API

/**
 * Creates a new task processor that coordinates task stages via events.
 * All configuration methods should be chainable.
 */
class TaskProcessor {
  /**
   * Starts processing a task, triggering the event chain.
   * @param {Object} task - The task data to process
   */
  start(task) {
    // IMPLEMENTATION HERE
  }
}

module.exports = { TaskProcessor };

Dependencies { .dependencies }

wolfy87-eventemitter { .dependency }

Provides event management capabilities with chaining support.

Install with Tessl CLI

npx tessl i tessl/npm-wolfy87-eventemitter

tile.json