Registry / testing / can-event-queue

can-event-queue

JSON →
library1.1.8jsnpmunverified

can-event-queue provides a mixin that adds event binding and dispatching methods using can-queues, including legacy addEventListener and removeEventListener. It is part of the CanJS ecosystem, currently at version 1.1.8 with stable maintenance. This package is not intended for new projects; it is maintained for backward compatibility with older CanJS applications that depend on queue-based event dispatching. Key differentiator: it uses can-queues for asynchronous event handling, which is more complex than standard EventTarget.

npm install can-event-queue
INSTALL
IMPORT
SIG · CAN-EVENT-QUEUE
C
can-event-queue
testingjavascriptv1.1.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import CanEventQueue from 'can-event-queue';
const CanEventQueue = require('can-event-queue');
ESM default import; require() still works but is not recommended for new code.
eventQueueMixin
import { eventQueueMixin } from 'can-event-queue';
import eventQueueMixin from 'can-event-queue';
Named export; common mistake to use default import.
EventQueue
import { EventQueue } from 'can-event-queue';
import EventQueue from 'can-event-queue';
Named export for the EventQueue class; also available as default?

Shows how to mix in event queue behavior into a custom class, then add an event listener and dispatch an event.

import CanEventQueue from 'can-event-queue'; import queues from 'can-queues'; // Create a class that mixes in event queue behavior class MyClass { constructor() { CanEventQueue.call(this); } } // Mixin: copy CanEventQueue methods to prototype Object.assign(MyClass.prototype, CanEventQueue.prototype); const instance = new MyClass(); instance.addEventListener('custom', function(ev) { console.log('Event received:', ev.detail); }); // Dispatch an event instance.dispatchEvent(new CustomEvent('custom', { detail: 'hello' })); // After queuing, events are dispatched asynchronously console.log('Event dispatched (queued)');
Debug
Known issues
deprecatedThis package is not intended for new packages.
fix
Use standard EventTarget or a modern event library instead.
affects: >=1.0.0
gotchaEvents dispatched via dispatchEvent are queued and not handled synchronously; handlers run after the current task completes.
fix
Ensure that event handlers are not expected to run before the next line of code.
affects: >=1.0.0
gotchaRequires can-queues as a peer dependency; must be installed separately.
fix
Install can-queues: npm install can-queues
affects: >=1.0.0
breakingESM named exports changed order in v1.1.0; eventQueueMixin might not be directly accessible.
fix
Use default import or check exports.
affects: =1.1.0
Errors
Common errors & fixes
TypeError: instance.addEventListener is not a function
Did not properly mix in CanEventQueue methods to the prototype.
fix
Use Object.assign(MyClass.prototype, CanEventQueue.prototype); after defining the class.
Cannot find module 'can-queues'
can-queues is a required peer dependency not installed.
fix
Run npm install can-queues
Upgrade
Version history
1.1.8latest on npm
Audit
Dependencies
can-queuesrequiredProvides the queue mechanism for event dispatching
Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources
can-event-queue — npm install can-event-queue · libregistry