Spark - Javascript

Spark Javascript is a fast, micro size DOM custom event emitter library.

  1. Contents
  2. Usage
  3. Sample
  4. Arguments

Usage

<script src="./dist/spark.min.js"></script>
// attach an event listener
element.addEventListener('event', function(e){
	// print: Object {foo:"bar"}
	console.log(e.detail)
});

// trigger the event
spark(element, 'event', {foo:'bar'});

Sample

0

Arguments

spark(element [object], event [string], data [object][optional]);

element
Type: Object

The DOM element specified to dispatche either a native or custom event at.


event
Type: String

Either a native or custom event to dispatche at the specified target.


data
Type: Any

A CustomEventInit dictionary, optional and defaulting to null, that is an event-dependent value associated with the event.